Re: ONLINE SERVER TO STORE AND RUN PYTHON SCRIPTS
On Monday, 20 August 2012 07:05:27 UTC+5:30, Jerry Hill wrote: > On Sun, Aug 19, 2012 at 6:27 PM, coldfire wrote: > > > Also I have no idea how to deploy a python script online. > > > I have done that on my local PC using Apache server and cgi but it Works > > fine. > > > Whats this all called? as far as I have searched its Web Framework but I > > dont wont to develop a website Just a Server which can run my scripts at > > specific time and send me email if an error occurs. > > > I use Python And i am not getting any lead. > > > > If you want to host web pages, like your're doing on your local pc > > with Apache and cgi, then you need an account with a web server, and a > > way to deploy your scripts and other content. This is often known as > > a 'web hosting service'[1]. The exact capabilities and restrictions > > will vary from provider to provider. > > > > If you just want an alway-on, internet accessable place to store and > > run your python scripts, you may be interested in a 'shell > > account'[2], or if you need more control over the environment, a > > 'virtual private server'[3]. > > > > That may give you a few terms to google, and see what kind of service you > need. > > > > 1 http://en.wikipedia.org/wiki/Shell_account > > 2 http://en.wikipedia.org/wiki/Web_host > > 3 http://en.wikipedia.org/wiki/Virtual_private_server > > > > -- > > Jerry Thanks a ton I will look into these and Get back to u -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
On 20/08/2012 02:57, kj wrote:
In Roy Smith writes:
In article , kj
wrote:
As far as I've been able to determine, Python does not remember
(immutably, that is) the working directory at the program's start-up,
or, if it does, it does not officially expose this information.
Why would you expect that it would? What would it (or you) do with this
information?
More to the point, doing a chdir() is not something any library code
would do (at least not that I'm aware of), so if the directory changed,
it's because some application code did it. In which case, you could
have just stored the working directory yourself.
This means that no library code can ever count on, for example,
being able to reliably find the path to the file that contains the
definition of __main__. That's a weakness, IMO. One manifestation
of this weakness is that os.chdir breaks inspect.getmodule, at
least on Unix. If you have some Unix system handy, you can try
the following. First change the argument to os.chdir below to some
valid directory other than your working directory. Then, run the
script, making sure that you refer to it using a relative path.
When I do this on my system (OS X + Python 2.7.3), the script bombs
at the last print statement, because the second call to inspect.getmodule
(though not the first one) returns None.
import inspect
import os
frame = inspect.currentframe()
print inspect.getmodule(frame).__name__
os.chdir('/some/other/directory') # where '/some/other/directory' is
# different from the initial directory
print inspect.getmodule(frame).__name__
...
% python demo.py
python demo.py
__main__
Traceback (most recent call last):
File "demo.py", line 11, in
print inspect.getmodule(frame).__name__
AttributeError: 'NoneType' object has no attribute '__name__'
I don't know of any way to fix inspect.getmodule that does not
involve, directly or indirectly, keeping a stable record of the
starting directory.
But, who am I kidding? What needs fixing, right? That's not a
bug, that's a feature! Etc.
By now I have learned to expect that 99.99% of Python programmers
will find that there's nothing wrong with behavior like the one
described above, that it is in fact exactly As It Should Be, because,
you see, since Python is the epitome of perfection, it follows
inexorably that any flaw or shortcoming one may *perceive* in Python
is only an *illusion*: the flaw or shortcoming is really in the
benighted programmer, for having stupid ideas about programming
(i.e. any idea that may entail that Python is not *gasp* perfect).
Pardon my cynicism, but the general vibe from the replies I've
gotten to my post (i.e. "if Python ain't got it, it means you don't
need it") is entirely in line with these expectations.
I see, I see, I get the picture. You're in the "The OS is flawed so I
expect the Python core developers to do my work for me by producing code
that gets around every known flaw in every supported OS" club. Somehow
I don't think that will happen.
--
Cheers.
Mark Lawrence.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
On 20/08/2012 04:04, alex23 wrote: My apologies for any double-ups and bad formatting. The new Google Groups interface seems to have effectively shat away decades of UX for something that I can only guess was generated randomly. It's very useful for reporting spam. Otherwise Thunderbird is go :) -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: ONLINE SERVER TO STORE AND RUN PYTHON SCRIPTS
On 20/08/2012 08:03, coldfire wrote: Thanks a ton I will look into these and Get back to u Could we have plain English please and not text speech, thanks. If nothing else that should help the people whose English is a second or higher numbered language. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)
On Aug 19, 12:15 pm, Steven D'Aprano wrote: > is probably a really great person and kind to small animals and furry > children, but... ROFL! The first we're all familiar with. Furry children? Something to do with heads the size of a planet? -- http://mail.python.org/mailman/listinfo/python-list
Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)
On Mon, Aug 20, 2012 at 5:31 PM, rusi wrote: > On Aug 19, 12:15 pm, Steven D'Aprano [email protected]> wrote: >> is probably a really great person and kind to small animals and furry >> children, but... > > ROFL! > > The first we're all familiar with. > > Furry children? > > Something to do with heads the size of a planet? Or it's a Wonka-esque "Wait. Scratch that. Reverse it" moment. Of course Steven is a bit egotistical. That sort of happens when you're better than 95% of the human population of this planet. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
How to convert base 10 to base 2?
Hi,
as you can argue from the subject, i'm really,really new to python.
What is the best way to achieve that with python? Because the syntax
int('30',2) doesn't seem to work!
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to convert base 10 to base 2?
On Mon, Aug 20, 2012 at 12:50 AM, wrote:
> Hi,
> as you can argue from the subject, i'm really,really new to python.
> What is the best way to achieve that with python? Because the syntax
> int('30',2) doesn't seem to work!
That syntax goes the other way- from a string representing a number in
the given base into an integer (which doesn't have a base, although
it's stored in base 2).
You get the binary by doing bin(x), where x is an integer.
>>> bin(12)
'0b1100'
If you want to go from a string in base-10 to a string in base-2, you
have to do the conversion to integer first.
>>> bin(int('5',10))
'0b101'
Although you don't need to specify the 10 because that's the default.
>>> bin(int('5'))
'0b101'
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to convert base 10 to base 2?
On 20/08/2012 08:50, [email protected] wrote: Hi, as you can argue from the subject, i'm really,really new to python. What is the best way to achieve that with python? Because the syntax int('30',2) doesn't seem to work! When you have a problem please cut and paste the exact thing that you tried with the entire traceback. "Doesn't seem to work" doesn't tell us a lot. Your OS and Python version is usually needed as well but we might be able to skip those details in this case :) How much general programming experience do you have? -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)
On 20/08/2012 08:46, Chris Angelico wrote: On Mon, Aug 20, 2012 at 5:31 PM, rusi wrote: On Aug 19, 12:15 pm, Steven D'Aprano wrote: is probably a really great person and kind to small animals and furry children, but... ROFL! The first we're all familiar with. Furry children? Something to do with heads the size of a planet? Or it's a Wonka-esque "Wait. Scratch that. Reverse it" moment. Of course Steven is a bit egotistical. That sort of happens when you're better than 95% of the human population of this planet. ChrisA He's a long way to go to catch up with me then :) -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert base 10 to base 2?
On 20/08/12 08:50, [email protected] wrote: Hi, as you can argue from the subject, i'm really,really new to python. What is the best way to achieve that with python? Because the syntax int('30',2) doesn't seem to work >>> x = bin(30)[2:] >>> x '0' >>> int(x, 2) 30 >>> lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun -- http://mail.python.org/mailman/listinfo/python-list
Re: Abuse of Big Oh notation
On Sun, 19 Aug 2012 16:42:03 -0700, Paul Rubin wrote: Steven D'Aprano writes: > Of course *if* k is constant, O(k) is constant too, but k is not > constant. In context we are talking about string indexing and slicing. > There is no value of k, say, k = 2, for which you can say "People will > sometimes ask for string[2] but never ask for string[3]". That is absurd. The context was parsing, e.g. recognizing a token like "a" or "foo" in a human-written chunk of text. Occasionally it might be "sesquipidalian" or some even worse outlier, but one can reasonably put a fixed and relatively small upper bound on the expected value of k. That makes the amortized complexity O(1), I think. No it doen't. It is still O(k). The point of big O notation is to understand the asymptotic behaviour of one variable as it becomes large because of changes in other variables. If k is small then you can often guess that O(k) is small. To say that an operation is O(k), however, is a statement about what happens when k is big (and is not refuted by saying that k is typically not big). Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert base 10 to base 2?
On Monday, August 20, 2012 9:50:53 AM UTC+2, (unknown) wrote:
> Hi,
>
> as you can argue from the subject, i'm really,really new to python.
>
> What is the best way to achieve that with python? Because the syntax
> int('30',2) doesn't seem to work!
Thank you all for the big help!
@Mark Lawrence
Yes, you're definetely right: i should have posted my OS and the version but
being a very rough question on syntax i thought it didn't really matter.
I've quite a good general programming experience. I know Java,Visual
Basic.NET,Pascal and Mathematica.
--
http://mail.python.org/mailman/listinfo/python-list
How to set the socket type and the protocol of a socket using create_connection?
Hello everyone,
I want to use socket.create_connection(...) to set a source address in a ping
implementation in python.
But how can I then set the type and the protocol? Because, before, I did:
icmp = socket.getprotobyname("icmp")
my_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)
But now, I do:
src_addr = socket.gethostbyname(src_addr)
dest_addr = socket.gethostbyname(dest_addr)
my_socket = socket.create_connection(dest_addr, socket.getdefaulttimeout(),
src_addr)
Is there something like my_socket.setproto()? I haven't found such a function
in the documentation.
Thank you,
Guillaume
--
http://mail.python.org/mailman/listinfo/python-list
[CGI] Basic newbie error or server configuration error?
Hello
Apache fails running this basic CGI script that I found on the Net:
www.acme.com/cgi-bin/test.py?name=myname
===
#!/usr/bin/env python
# Import modules for CGI handling
import cgi, cgitb
cgitb.enable()
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from field 'name'
#name = form['name'].value
name = form.getvalue('name')
===
This is what I get:
===
"Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request."
===
FWIW, the script lives in www/cgi-bin/ where it should, was chmoded to
755, and I put the following .htaccess file:
===
Options +ExecCGI
AddHandler cgi-script .py
===
I'm not sure where to look for an error. Could it be some non-printed,
bad characters that prevent Python from compiling the source code?
Thanks for any help.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
2012/8/20 kj :
> In Roy Smith
> writes> This means that no library code can ever count on, for example,
> being able to reliably find the path to the file that contains the
> definition of __main__. That's a weakness, IMO. One manifestation
> of this weakness is that os.chdir breaks inspect.getmodule, at
> least on Unix. If you have some Unix system handy, you can try
> the following. First change the argument to os.chdir below to some
> valid directory other than your working directory. Then, run the
> script, making sure that you refer to it using a relative path.
> When I do this on my system (OS X + Python 2.7.3), the script bombs
> at the last print statement, because the second call to inspect.getmodule
> (though not the first one) returns None.
>
> import inspect
> import os
>
> frame = inspect.currentframe()
>
> print inspect.getmodule(frame).__name__
>
> os.chdir('/some/other/directory') # where '/some/other/directory' is
> # different from the initial directory
>
> print inspect.getmodule(frame).__name__
>
> ...
>
> % python demo.py
> python demo.py
> __main__
> Traceback (most recent call last):
> File "demo.py", line 11, in
> print inspect.getmodule(frame).__name__
> AttributeError: 'NoneType' object has no attribute '__name__'
>
>..
As in many other cases the programming language can't possibly act
safely on all the possible stupid things that the programmer wants to
do, and not understanding how an operating system works doesn't help
either..
In the specific case there is absolutely no use of os.chdir, since you
can:
- use absolute paths
- things like subprocess.Popen accept a cwd argument
- at worst you can chdir back to the previous position right after the
broken thing that require a certain path that you are calling is run
--
http://mail.python.org/mailman/listinfo/python-list
Re: [CGI] Basic newbie error or server configuration error?
Found it: The script MUST return something to the browser. I was missing this: print "Content-Type: text/html;charset=utf-8" print # print a document print "Name is %s" % ( cgi.escape(name), ) Sorry about that. -- http://mail.python.org/mailman/listinfo/python-list
Re: [CGI] Basic newbie error or server configuration error?
On Mon, 20 Aug 2012 13:41:20 +0200
Gilles wrote:
> Hello
>
> Apache fails running this basic CGI script that I found on the Net:
>
> www.acme.com/cgi-bin/test.py?name=myname
> ===
> #!/usr/bin/env python
>
> # Import modules for CGI handling
> import cgi, cgitb
>
> cgitb.enable()
>
> # Create instance of FieldStorage
> form = cgi.FieldStorage()
>
> # Get data from field 'name'
> #name = form['name'].value
> name = form.getvalue('name')
> ===
>
> This is what I get:
> ===
> "Internal Server Error
>
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.
>
> Additionally, a 404 Not Found error was encountered while trying to
> use an ErrorDocument to handle the request."
> ===
>
> FWIW, the script lives in www/cgi-bin/ where it should, was chmoded to
> 755, and I put the following .htaccess file:
> ===
> Options +ExecCGI
> AddHandler cgi-script .py
> ===
>
> I'm not sure where to look for an error. Could it be some non-printed,
> bad characters that prevent Python from compiling the source code?
>
> Thanks for any help.
Check the Apache error log, there should be more information there.
--
Rod Person http://www.rodperson.com [email protected]
Sent From Claws Mail 3.8.0cvs30 Win7 x86 GTK+ 2.16.6/GLib 2.24.0
--
http://mail.python.org/mailman/listinfo/python-list
ANN: eGenix mxODBC Connect - Python Database Interface 2.0.0
ANNOUNCING eGenix.com mxODBC Connect Python Database Interface Version 2.0.0 mxODBC Connect is our commercially supported client-server product for connecting Python applications to relational databases in a truly cross-platform way. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mxODBC-Connect-2.0.0-GA.html INTRODUCTION The mxODBC Connect Database Interface for Python allows users to easily connect Python applications to all major databases on the market today in a highly portable, convenient and secure way. Python Database Connectivity the Easy Way Unlike our mxODBC Python extension, mxODBC Connect is designed as client-server application, so you no longer need to find production quality ODBC drivers for all the platforms you target with your Python application. Instead you use an easy to install Python client library which connects directly to the mxODBC Connect database server over the network. This makes mxODBC Connect a great basis for writing cross-platform multi-tier database applications and utilities in Python, especially if you run applications that need to communicate with databases such as MS SQL Server and MS Access, Oracle Database, IBM DB2 and Informix, Sybase ASE and Sybase Anywhere, MySQL, PostgreSQL, SAP MaxDB and many more, that run on Windows or Linux machines. Ideal for Database Driven Client Applications By removing the need to install and configure ODBC drivers on the client side and dealing with complicated network setups for each set of drivers, mxODBC Connect greatly simplifies deployment of database driven client applications, while at the same time making the network communication between client and database server more efficient and more secure. For more information, please have a look at the mxODBC Connect product page, in particular, the full list of available features. For more information, please see the product page: http://www.egenix.com/products/python/mxODBCConnect/ NEWS mxODBC Connect 2.0.0 is a new major release of our successful mxODBC Connect product. Enhanced API * mxODBC Connect Server now uses mxODBC 3.2 internally and makes its API available in the mxODBC Connect Client. This is a major step forward from the mxODBC 3.0 version used in mxODBC Connect Server 1.0. * mxODBC Connect Client comes with all the mxODBC enhancements, including: - connection and cursor objects can be used as context managers - adjustable parameter styles (qmark or named) - connection .autocommit attribute to easily switch on autocommit - adjustable timestamp resolution - new possibilities to set connection and cursor options to adjust the ODBC objects to your application needs, e.g. set a connection read-only or set a query timeout - adjustable decimal, datetime and string formats - adjustable warning format to be able to handle server warnings without client interaction - greatly improved result set scrolling support - Unicode support for all catalog methods - Access to additional result set meta data via cursor.getcolattribute() Updated Compatibility * The server now features all the ODBC driver compatibility enhancements provided by mxODBC 3.2, including improved and updated support for MS SQL Server Native Client, Oracle Instant Client, Sybase ASE, IBM DB2, Teradata and Netezza. * Native Windows x64 builds with signed executables and a tray app rewritten in C are available for Windows 2008R2, Vista and 7 x64, so you can benefit from better performance, fewer UAC dialogs and smaller memory footprint. Asynchronous Execution * mxODBC Connect Client now integrates directly with gevent, allowing client applications to run asynchronous tasks while performing remote database queries. Better Integration * mxODBC Connect now uses the official IANA registered port 6632 for both plain text and SSL-encrypted communication. * mxODBC Connect Client now allows selecting the used SSL module from two available options: Python standard lib ssl module and pyOpenSSL. For the full set of changes, please check the mxODBC Connect change log. http://www.egenix.com/products/python/mxODBCConnect/changelog.html UPGRADING You are encouraged to upgrade to this latest mxODBC Connect release. When upgrading, please always upgrade both the server and the client installations to the same version - even for patch level releases. Customers who have purchased mxODBC Connect 2.0 licenses can request 20% discount co
Re: How to set the socket type and the protocol of a socket using create_connection?
In fact, socket.create_connection is for TCP only so I cannot use it for a ping implementation. Does anyone have an idea about how to be able to set a source address for ICMP messages? -- http://mail.python.org/mailman/listinfo/python-list
Re: How does .rjust() work and why it places characters relative to previous one, not to first character - placed most to left - or to left side of screen?
crispy wrote:
> Thanks, i've finally came to solution.
>
> Here it is -> http://codepad.org/Q70eGkO8
>
> def pairwiseScore(seqA, seqB):
>
> score = 0
> bars = [str(' ') for x in seqA] # ...
> length = len(seqA)
> similarity = []
>
> for x in xrange(length):
>
> if seqA[x] == seqB[x]: # ...
> if (x >= 1) and (seqA[x - 1] == seqB[x - 1]): # ...
> score += 3
> similarity.append(x)
> else:
> score += 1
> similarity.append(x)
> else:
> score -= 1
>
> for x in similarity:
> bars[x] = '|' # ...
>
> return ''.join((seqA, '\n', ''.join(bars), '\n', seqB, '\n', 'Score:
', str(score)))
>
Python has a function zip() that lets you iterate over multiple sequences
simultaneously. Instead of
for i in xrange(len(a)):
x = a[i]
y = b[i]
...
you can write
for x, y in zip(a, b):
...
Also, you can build the bar list immediately and avoid the similarity list.
With these changes:
def pairwise_score(a, b):
score = 0
was_equal = False
bars = []
for x, y in zip(a, b):
equal = x == y
if equal:
bars.append("|")
if was_equal:
score += 3
else:
score += 1
else:
bars.append(" ")
score -= 1
was_equal = equal
print a
print "".join(bars)
print b
print "Score:", score
If you want to take this even further you can use a score matrix instead of
if ... else:
def pairwise_score(a, b):
score = 0
was_equal = False
bars = []
matrix = [[-1, 1], [-1, 3]]
for x, y in zip(a, b):
equal = x == y
score += matrix[was_equal][equal]
bars.append(" |"[equal])
was_equal = equal
print a
print "".join(bars)
print b
print "Score:", score
--
http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
On Mon, 20 Aug 2012 12:56:42 +0100, andrea crotti wrote: > In the specific case there is absolutely no use of os.chdir, since you > can: > - use absolute paths > - things like subprocess.Popen accept a cwd argument - at worst you can > chdir back to the previous position right after the broken thing that > require a certain path that you are calling is run I wouldn't say so much that there's "absolutely no use", it's more that there are other, safer, ways to get the same result. As I understand it, os.chdir is more for the convenience of sys admins who want to write quick scripts in Python than a function intended to be used in libraries or major applications. An interesting question is, what do other languages do in this case? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: New internal string format in 3.3
In article , Michael Torrie wrote: > Python generally tries to follow unicode > encoding rules to the letter. Thus if a piece of text cannot be > represented in the character set of the terminal, then Python will > properly err out. Other languages you have tried, likely fudge it > somehow. And if you want the "fudge it somehow" behavior (which is often very useful!), there's always http://pypi.python.org/pypi/Unidecode/ -- http://mail.python.org/mailman/listinfo/python-list
python 6 compilation failure on RHEL
Hi All, We are trying python 2.6 installation on an RHEL PC , whose 'uname -a' is (Linux 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux ) But, python compilation is not successfully done and showing a failure log. Below is the capture of the same. Please see failure log shown in the bottom of this mail. How to solve the failure modules mentioned in the log ( bsddb185, dl , imageop, sunaudiodev ) Please guide me to proceed further. == capture begin = cd Python- 2.6.6 # ./configure checking for --enable-universalsdk... no checking for --with-universal-archs... 32-bit checking MACHDEP... linux2 checking EXTRAPLATDIR... checking machine type as reported by uname -m... x86_64 checking for --without-gcc... no checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for --with-cxx-main=... no checking for g++... g++ configure: WARNING: By default, distutils will build C++ extension modules with "g++". If this is not intended, then set CXX on the configure command line. checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking for --with-suffix... checking for case-insensitive build directory... no checking LIBRARY... libpython$(VERSION).a checking LINKCC... $(PURIFY) $(MAINCC) checking for --enable-shared... no checking for --enable-profiling... checking LDLIBRARY... libpython$(VERSION).a checking for ranlib... ranlib checking for ar... ar checking for svnversion... found checking for a BSD-compatible install... /usr/bin/install -c checking for --with-pydebug... no checking whether gcc accepts -fno-strict-aliasing... yes checking whether gcc accepts -OPT:Olimit=0... no checking whether gcc accepts -Olimit 1500... no checking whether gcc supports ParseTuple __format__... no checking whether pthreads are available without options... no checking whether gcc accepts -Kpthread... no checking whether gcc accepts -Kthread... no checking whether gcc accepts -pthread... yes checking whether g++ also accepts flags for thread support... yes checking for ANSI C header files... (cached) yes checking asm/types.h usability... yes checking asm/types.h presence... yes checking for asm/types.h... yes checking conio.h usability... no checking conio.h presence... no checking for conio.h... no checking curses.h usability... yes checking curses.h presence... yes checking for curses.h... yes checking direct.h usability... no checking direct.h presence... no checking for direct.h... no checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking errno.h usability... yes checking errno.h presence... yes checking for errno.h... yes checking fcntl.h usability... yes checking fcntl.h presence... yes checking for fcntl.h... yes checking grp.h usability... yes checking grp.h presence... yes checking for grp.h... yes checking ieeefp.h usability... no checking ieeefp.h presence... no checking for ieeefp.h... no checking io.h usability... no checking io.h presence... no checking for io.h... no checking langinfo.h usability... yes checking langinfo.h presence... yes checking for langinfo.h... yes checking libintl.h usability... yes checking libintl.h presence... yes checking for libintl.h... yes checking ncurses.h usability... yes checking ncurses.h presence... yes checking for ncurses.h... yes checking poll.h usability... yes checking poll.h presence... yes checking for poll.h... yes checking process.h usability... no checking process.h presence... no checking for process.h... no checking pthread.h usability... yes checking pthread.h presence... yes checking for pthread.h... yes checking shadow.h usability... yes checking shadow.h presence... yes checking for shadow.h... yes checking signal.h usability... yes checking signal.h presence... yes checking for signal.h... yes checking for stdint.h... (cached) yes checking stropts.h usability... yes checking stropts.h presence... yes checking for stropts.h... yes checking termios.h usability... yes checking termios.h presence... yes checking for
Re: How to set the socket type and the protocol of a socket using create_connection?
On 20/08/12 14:36:58, Guillaume Comte wrote: > In fact, socket.create_connection is for TCP only so I cannot use it for a > ping implementation. Why are you trying to reimplement ping? All OS'es I am aware of come with a working ping implementation. > Does anyone have an idea about how to be able to set a source address for > ICMP messages? Did you try not setting it? The default is probably your own IP address, which is the only sensible value anyway. Or are you trying to cause confusion by sending ICMP packets with a forged source address? -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On 8/20/2012 6:31 AM Ganesh Reddy K said... But, python compilation is not successfully done and showing a failure log. Below is the capture of the same. Please see failure log shown in the bottom of this mail. How to solve the failure modules mentioned in the log ( bsddb185, dl , imageop, sunaudiodev ) Please guide me to proceed further. You're done, unless you specifically need support for any of those specific modules. Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
On Mon, 20 Aug 2012 13:14:02 +, Steven D'Aprano wrote: > On Mon, 20 Aug 2012 12:56:42 +0100, andrea crotti wrote: > >> In the specific case there is absolutely no use of os.chdir, since you >> can: >> - use absolute paths - things like subprocess.Popen accept a cwd >> argument - at worst you can chdir back to the previous position right >> after the broken thing that require a certain path that you are calling >> is run > > > I wouldn't say so much that there's "absolutely no use", it's more that > there are other, safer, ways to get the same result. > > As I understand it, os.chdir is more for the convenience of sys admins > who want to write quick scripts in Python than a function intended to be > used in libraries or major applications. > I don't disagree, but in my experience few sysadmins use Python; they use shell scripts. And these seldom do a 'cd' anyway - they will normally operate irrespective of the current working directory. It is difficult to think of a sensible use for os.chdir, IMHO. > An interesting question is, what do other languages do in this case? -- http://mail.python.org/mailman/listinfo/python-list
Re: [CGI] Basic newbie error or server configuration error?
On Mon, 20 Aug 2012 07:59:39 -0400, Rod Person wrote: >Check the Apache error log, there should be more information there. It's a shared account, so I only have access to what's in cPanel, which didn't display anything. Problem solved. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
In article , Walter Hurry wrote: > It is difficult to think of a sensible use for os.chdir, IMHO. It is true that you can mostly avoid chdir() by building absolute pathnames, but it's often more convenient to just cd somewhere and use names relative to that. Fabric (a very cool tool for writing remote sysadmin scripts), gives you a cd() command which is a context manager, making it extra convenient. Also, core files get created in the current directory. Sometimes daemons will cd to some fixed location to make sure that if they dump core, it goes in the right place. On occasion, you run into (poorly designed, IMHO) utilities which insist of reading or writing a file in the current directory. If you're invoking one of those, you may have no choice but to chdir() to the right place before running them. -- http://mail.python.org/mailman/listinfo/python-list
Does Polymorphism mean python can create object?
Does Polymorphism mean python can create object? -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
2012/8/20 Roy Smith :
> In article ,
> Walter Hurry wrote:
>
>> It is difficult to think of a sensible use for os.chdir, IMHO.
>
> It is true that you can mostly avoid chdir() by building absolute
> pathnames, but it's often more convenient to just cd somewhere and use
> names relative to that. Fabric (a very cool tool for writing remote
> sysadmin scripts), gives you a cd() command which is a context manager,
> making it extra convenient.
>
> Also, core files get created in the current directory. Sometimes
> daemons will cd to some fixed location to make sure that if they dump
> core, it goes in the right place.
>
> On occasion, you run into (poorly designed, IMHO) utilities which insist
> of reading or writing a file in the current directory. If you're
> invoking one of those, you may have no choice but to chdir() to the
> right place before running them.
> --
> http://mail.python.org/mailman/listinfo/python-list
I've done quite a lot of system programming as well, and changing
directory is only a source of possible troubles in general.
If I really have to for some reasons I do this
class TempCd:
"""Change temporarily the current directory
"""
def __init__(self, newcwd):
self.newcwd = newcwd
self.oldcwd = getcwd()
def __enter__(self):
chdir(self.newcwd)
return self
def __exit__(self, type, value, traceback):
chdir(self.oldcwd)
with TempCd('/tmp'):
# now working in /tmp
# now in the original
So it's not that hard to avoid problems..
--
http://mail.python.org/mailman/listinfo/python-list
Re: Does Polymorphism mean python can create object?
On Tue, Aug 21, 2012 at 12:01 AM, Levi Nie wrote: > Does Polymorphism mean python can create object? I'm not sure what your question means. Could you rephrase, please? Also, this document may be useful to you: http://www.catb.org/~esr/faqs/smart-questions.html Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
kj wrote: 99.99% of Python programmers will find that there's nothing wrong with behavior [snip] Pardon my cynicism, but the general vibe from the replies I've gotten to my post (i.e. "if Python ain't got it, it means you don't need it") [snip] Don't you find there's something wrong in applying your observation from 2 or 3 replies to your post to 99% of python programmer ? Moreover, flaming people on their own mailing list won't do you any good, ever, in any list. To get back to your original question, > inspect.getmodule? Docstring: Return the module an object was defined in, or None if not found. As getmodule may return None if not found, you need too handle that case. There's possibly a weakness in the inspect module when changing the current directory however nothing wrong with Python having the remember the intial directory. If you need to remember it, do it youself (or file a bug to inspect module authors). JM -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert base 10 to base 2?
[email protected] wrote: On Monday, August 20, 2012 9:50:53 AM UTC+2, (unknown) wrote: Hi, as you can argue from the subject, i'm really,really new to python. What is the best way to achieve that with python? Because the syntax int('30',2) doesn't seem to work! Thank you all for the big help! @Mark Lawrence Yes, you're definetely right: i should have posted my OS and the version but being a very rough question on syntax i thought it didn't really matter. I've quite a good general programming experience. I know Java,Visual Basic.NET,Pascal and Mathematica. note that the builtin bin function is not available with python ver < 2.6 def Denary2Binary(n): '''convert denary integer n to binary string bStr''' bStr = '' if n < 0: raise ValueError, "must be a positive integer" if n == 0: return '0' while n > 0: bStr = str(n % 2) + bStr n = n >> 1 return bStr JM (not my function but I can't remember who I stole from) -- http://mail.python.org/mailman/listinfo/python-list
Re: [CGI] Basic newbie error or server configuration error?
On 20/08/12 15:50:43, Gilles wrote: > On Mon, 20 Aug 2012 07:59:39 -0400, Rod Person > wrote: >> Check the Apache error log, there should be more information there. > > It's a shared account, so I only have access to what's in cPanel, > which didn't display anything. Most such panels have a button to show the error log for your own site. If you can't find it, ask the help desk of the web hosting company. If there really is no way for you to see the error log, ask the help desk to mail you the error message. -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)
Zero Piraeus wrote: : On 17 August 2012 21:43, Steven D'Aprano wrote: There are cultures that marry five year old girls to sixty year old men, cultures that treat throwing acid in the faces of women as acceptable behaviour, cultures that allow war heroes to die of hunger and cold homeless in the street, and cultures that top-post. What's your point? +1 QOTW -[]z. We're closer to the +1 godwin point JM -- http://mail.python.org/mailman/listinfo/python-list
Re: How to set the socket type and the protocol of a socket using create_connection?
Le lundi 20 août 2012 15:38:14 UTC+2, Hans Mulder a écrit : > On 20/08/12 14:36:58, Guillaume Comte wrote: > > > In fact, socket.create_connection is for TCP only so I cannot use it for a > > ping implementation. > > > > Why are you trying to reimplement ping? Because I work on a network emulator and I want to check biterros patterns so I need to access the data of the packets. An dsince my test program is written in Python, it's easier to do it in Python. > > > > All OS'es I am aware of come with a working ping implementation. > > > > > > > Does anyone have an idea about how to be able to set a source address for > > ICMP messages? > > > > Did you try not setting it? > > > > The default is probably your own IP address, which is the only > > sensible value anyway. Or are you trying to cause confusion > > by sending ICMP packets with a forged source address? No, I want to do it on a machine with aliases as in: ifconfig em0 10.0.1.1 netmask 255.255.255.0 alias ifconfig em0 10.0.2.1 netmask 255.255.255.0 alias ping -c4 -S 10.0.1.1 10.0.2.1 But I think I've found the solution: my_socket.bind((src_addr, 1)) > > > > -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: How to set the socket type and the protocol of a socket using create_connection?
On Mon, Aug 20, 2012 at 11:38 PM, Hans Mulder wrote: > Why are you trying to reimplement ping? > > All OS'es I am aware of come with a working ping implementation. For some definition of "working", at least. I've never managed to get MS Windows to ping broadcast, for instance. A Google search for 'python ping' comes up with a few good answers, though. You may want to have a look at some of them; if nothing else, you'll get confirmation that what you're doing corresponds to what someone else has done (which isn't proof you're doing the right thing, but it does suggest it). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: [CGI] Basic newbie error or server configuration error?
On Mon, 20 Aug 2012 16:56:14 +0200, Hans Mulder wrote: >Most such panels have a button to show the error log for your own site. > >If you can't find it, ask the help desk of the web hosting company. > >If there really is no way for you to see the error log, ask the help >desk to mail you the error message. Thanks. the cPanel at my provider only has a Logs > Error Log icon, but the error I was having didn't result in anything in the log file. I'll set up a Linux host at home and test Python scripts before uploading them to my ISP. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Abuse of Big Oh notation
Oscar Benjamin writes: > No it doen't. It is still O(k). The point of big O notation is to > understand the asymptotic behaviour of one variable as it becomes > large because of changes in other variables. Actually, two separate problems got mixed together late at night. In neither case is k an independent variable that ranges over all possible values. In both cases it is selected or observed by measurement (i.e. it is a dependent variable determined by something that is itself not independent). 1) Access in a rope: here, k is basically determined by the pointer size of the computer, which in CPython (the implementation we're discussing) the pointer size is 4 or 8 bytes (constants) in all instances AFAIK. k should be a big enough that the pointer and allocation overhead is small compared to bloating the strings with UCS-2 or UCS-4, and small enough to not add much scan time. It seems realistic to say k<=128 for this (several times smaller is probably fine). 128 is of course a constant and not a variable. We are not concerned about hypothetical computers with billion bit pointers. 2) Parsing tokens: here, k is drawn from a fixed probability distribution such that its expectation value is again a small constant (this is an assertion about the data looks like in typical parsing applications in the real world, not what is mathematically possible). The average-case complexity (I said "amortized" earlier but should have said "average-case") is proportional to that constant, which is to say, O(1). Of course there is still more wiggle room about what is "typical". Analogy: how big a box is required to hold a pair of shoes? In a purely theoretical sense we might say O(S) where S is the shoe size, treating shoe size as an arbitrary independent variable. But in the real world, shoe size is controlled by the size of human feet, which is bounded by a constant for biological reasons. You don't have to consider shoes the size of Jupiter. So it is O(1). -- http://mail.python.org/mailman/listinfo/python-list
Re: Abuse of Big Oh notation
On Tue, Aug 21, 2012 at 2:01 AM, Paul Rubin wrote: > Analogy: how big a box is required to hold a pair of shoes? In a purely > theoretical sense we might say O(S) where S is the shoe size, treating > shoe size as an arbitrary independent variable. But in the real world, > shoe size is controlled by the size of human feet, which is bounded by a > constant for biological reasons. You don't have to consider shoes the > size of Jupiter. So it is O(1). By that argument, everything is amortized O(1), because there's a limit on every variable. You can't possibly be working with a data set greater than the total sum of storage space in the entire world. That still doesn't mean that bubble sort and heap sort are equivalently efficient. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
woman in islam
woman in islam http://www.youtube.com/watch?v=ZXEScVFANvA&feature=related Thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
On 2012-08-20, kj wrote: > In Roy Smith > writes: > >>In article , kj >>wrote: > >>> As far as I've been able to determine, Python does not remember >>> (immutably, that is) the working directory at the program's start-up, >>> or, if it does, it does not officially expose this information. > >>Why would you expect that it would? What would it (or you) do with this >>information? > > This means that no library code can ever count on, for example, > being able to reliably find the path to the file that contains the > definition of __main__. What makes you think that the file that contains the definition of __main__ is the working directory on program startup? That's almost never the case in my experience. 2) Why should a library expect to be able to access the file containing the definition of __main__. > That's a weakness, IMO. You must be in possession of some rather odd use cases. I've been writing Python programs for something like 13 years, and I've never felt any need to have either an immutable record of the startup directory or access to the file containing the definition of __main__. > I don't know of any way to fix inspect.getmodule that does not > involve, directly or indirectly, keeping a stable record of the > starting directory. If what you really want is access to the definition of __main__, what does that have to do with the startup directory? If you want to know where __main__ is, you can probably figure it out from /proc/self/ -- Grant Edwards grant.b.edwardsYow! Am I having fun yet? at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Abuse of Big Oh notation
On 20 August 2012 17:01, Paul Rubin wrote: > Oscar Benjamin writes: > > No it doen't. It is still O(k). The point of big O notation is to > > understand the asymptotic behaviour of one variable as it becomes > > large because of changes in other variables. > > Actually, two separate problems got mixed together late at night. In > neither case is k an independent variable that ranges over all possible > values. In both cases it is selected or observed by measurement (i.e. > it is a dependent variable determined by something that is itself not > independent). > > 1) Access in a rope: here, k is basically determined by the pointer size > of the computer, which in CPython (the implementation we're discussing) > the pointer size is 4 or 8 bytes (constants) in all instances AFAIK. k > should be a big enough that the pointer and allocation overhead is small > compared to bloating the strings with UCS-2 or UCS-4, and small enough > to not add much scan time. It seems realistic to say k<=128 for this > (several times smaller is probably fine). 128 is of course a constant > and not a variable. We are not concerned about hypothetical computers > with billion bit pointers. > Okay, I see what you mean. If k is a hard-coded constant then it's not unreasonable to say that O(k) is constant time in relation to the input data (however big k is). Oscar. -- http://mail.python.org/mailman/listinfo/python-list
Re: Abuse of Big Oh notation
On Mon, Aug 20, 2012 at 10:09 AM, Chris Angelico wrote: > On Tue, Aug 21, 2012 at 2:01 AM, Paul Rubin wrote: >> Analogy: how big a box is required to hold a pair of shoes? In a purely >> theoretical sense we might say O(S) where S is the shoe size, treating >> shoe size as an arbitrary independent variable. But in the real world, >> shoe size is controlled by the size of human feet, which is bounded by a >> constant for biological reasons. You don't have to consider shoes the >> size of Jupiter. So it is O(1). > > By that argument, everything is amortized O(1), because there's a > limit on every variable. You can't possibly be working with a data set > greater than the total sum of storage space in the entire world. That > still doesn't mean that bubble sort and heap sort are equivalently > efficient. The difference between the two is that the former is bounded by a constant that is fundamental to the algorithm at hand, whereas the latter is bounded only by available resources. By any practical consideration the latter must be considered a variable, but the former need not be. Paul discusses above the asymptotic growth of a variable as O(S) where S is shoe size, but really this measure makes no sense in the first place. The question that this notation seeks to answer is, "What is the big-Oh behaviour of this variable as shoe size increases indefinitely (i.e. to infinity)?" and the answer in this case is "Shoe size does not increase indefinitely"; the question is invalid. A more logical question might be, "How much material do I need to construct N shoes of size S?" The answer to this question would presumably be some constant factor of N * S**2, which is O(N * S**2). Although N can be assumed to vary freely (up to nonsensical quantities like the mass of the entire universe), S is clearly bounded by the constraints of actual shoes, so we can safely treat S as a constant and call it O(N). -- http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On Mon, Aug 20, 2012 at 3:31 PM, Ganesh Reddy K wrote: > Hi All, > > We are trying python 2.6 installation on an RHEL PC , > > whose 'uname -a' is (Linux 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 > EST 2008 x86_64 x86_64 x86_64 GNU/Linux ) > > > But, python compilation is not successfully done and showing a failure > log. Below is the capture of the same. Please see failure log shown > in the bottom of this mail. > How to solve the failure modules mentioned in the log ( bsddb185, > dl , imageop, sunaudiodev ) > > Please guide me to proceed further. > > == capture begin = > cd Python- 2.6.6 > > # ./configure > checking for --enable-universalsdk... no > checking for --with-universal-archs... 32-bit > checking MACHDEP... linux2 > checking EXTRAPLATDIR... > checking machine type as reported by uname -m... x86_64 > checking for --without-gcc... no > checking for gcc... gcc > checking whether the C compiler works... yes > checking for C compiler default output file name... a.out > checking for suffix of executables... > checking whether we are cross compiling... no > checking for suffix of object files... o > checking whether we are using the GNU C compiler... yes > checking whether gcc accepts -g... yes > checking for gcc option to accept ISO C89... none needed > checking for --with-cxx-main=... no > checking for g++... g++ > configure: WARNING: > > By default, distutils will build C++ extension modules with "g++". > If this is not intended, then set CXX on the configure command line. > > checking how to run the C preprocessor... gcc -E > checking for grep that handles long lines and -e... /bin/grep > checking for egrep... /bin/grep -E > checking for ANSI C header files... yes > checking for sys/types.h... yes > checking for sys/stat.h... yes > checking for stdlib.h... yes > checking for string.h... yes > checking for memory.h... yes > checking for strings.h... yes > checking for inttypes.h... yes > checking for stdint.h... yes > checking for unistd.h... yes > checking minix/config.h usability... no > checking minix/config.h presence... no > checking for minix/config.h... no > checking whether it is safe to define __EXTENSIONS__... yes > checking for --with-suffix... > checking for case-insensitive build directory... no > checking LIBRARY... libpython$(VERSION).a > checking LINKCC... $(PURIFY) $(MAINCC) > checking for --enable-shared... no > checking for --enable-profiling... > checking LDLIBRARY... libpython$(VERSION).a > checking for ranlib... ranlib > checking for ar... ar > checking for svnversion... found > checking for a BSD-compatible install... /usr/bin/install -c > checking for --with-pydebug... no > checking whether gcc accepts -fno-strict-aliasing... yes > checking whether gcc accepts -OPT:Olimit=0... no > checking whether gcc accepts -Olimit 1500... no > checking whether gcc supports ParseTuple __format__... no > checking whether pthreads are available without options... no > checking whether gcc accepts -Kpthread... no > checking whether gcc accepts -Kthread... no > checking whether gcc accepts -pthread... yes > checking whether g++ also accepts flags for thread support... yes > checking for ANSI C header files... (cached) yes > checking asm/types.h usability... yes > checking asm/types.h presence... yes > checking for asm/types.h... yes > checking conio.h usability... no > checking conio.h presence... no > checking for conio.h... no > checking curses.h usability... yes > checking curses.h presence... yes > checking for curses.h... yes > checking direct.h usability... no > checking direct.h presence... no > checking for direct.h... no > checking dlfcn.h usability... yes > checking dlfcn.h presence... yes > checking for dlfcn.h... yes > checking errno.h usability... yes > checking errno.h presence... yes > checking for errno.h... yes > checking fcntl.h usability... yes > checking fcntl.h presence... yes > checking for fcntl.h... yes > checking grp.h usability... yes > checking grp.h presence... yes > checking for grp.h... yes > checking ieeefp.h usability... no > checking ieeefp.h presence... no > checking for ieeefp.h... no > checking io.h usability... no > checking io.h presence... no > checking for io.h... no > checking langinfo.h usability... yes > checking langinfo.h presence... yes > checking for langinfo.h... yes > checking libintl.h usability... yes > checking libintl.h presence... yes > checking for libintl.h... yes > checking ncurses.h usability... yes > checking ncurses.h presence... yes > checking for ncurses.h... yes > checking poll.h usability... yes > checking poll.h presence... yes > checking for poll.h... yes > checking process.h usability... no > checking process.h presence... no > checking for process.h... no > checking pthread.h usability... yes > checking pthread.h presence... yes > checking for pthread.h... yes > checking shadow.h usability... yes > checking shadow.h presence... yes > checking for shadow.h... yes > checkin
Re: python 6 compilation failure on RHEL
On Mon, 20 Aug 2012 19:12:05 +0200, Kwpolska wrote: > On Mon, Aug 20, 2012 at 3:31 PM, Ganesh Reddy K > wrote: >> Hi All, >> >> We are trying python 2.6 installation on an RHEL PC , >> >> whose 'uname -a' is (Linux 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 >> EST 2008 x86_64 x86_64 x86_64 GNU/Linux ) >> >> >> But, python compilation is not successfully done and showing a failure >> log. Below is the capture of the same. Please see failure log shown >> in the bottom of this mail. >> How to solve the failure modules mentioned in the log ( bsddb185, >> dl , imageop, sunaudiodev ) >> >> Please guide me to proceed further. >> >> == capture begin = >> cd Python- 2.6.6 >> >> # ./configure checking for --enable-universalsdk... no checking for >> --with-universal-archs... 32-bit checking MACHDEP... linux2 checking >> EXTRAPLATDIR... >> checking machine type as reported by uname -m... x86_64 checking for >> --without-gcc... no checking for gcc... gcc checking whether the C >> compiler works... yes checking for C compiler default output file >> name... a.out checking for suffix of executables... >> checking whether we are cross compiling... no checking for suffix of >> object files... o checking whether we are using the GNU C compiler... >> yes checking whether gcc accepts -g... yes checking for gcc option to >> accept ISO C89... none needed checking for >> --with-cxx-main=... no checking for g++... g++ >> configure: WARNING: >> >> By default, distutils will build C++ extension modules with "g++". If >> this is not intended, then set CXX on the configure command line. >> >> checking how to run the C preprocessor... gcc -E checking for grep that >> handles long lines and -e... /bin/grep checking for egrep... /bin/grep >> -E checking for ANSI C header files... yes checking for sys/types.h... >> yes checking for sys/stat.h... yes checking for stdlib.h... yes >> checking for string.h... yes checking for memory.h... yes checking for >> strings.h... yes checking for inttypes.h... yes checking for >> stdint.h... yes checking for unistd.h... yes checking minix/config.h >> usability... no checking minix/config.h presence... no checking for >> minix/config.h... no checking whether it is safe to define >> __EXTENSIONS__... yes checking for --with-suffix... >> checking for case-insensitive build directory... no checking LIBRARY... >> libpython$(VERSION).a checking LINKCC... $(PURIFY) $(MAINCC) >> checking for --enable-shared... no checking for --enable-profiling... >> checking LDLIBRARY... libpython$(VERSION).a checking for ranlib... >> ranlib checking for ar... ar checking for svnversion... found checking >> for a BSD-compatible install... /usr/bin/install -c checking for >> --with-pydebug... no checking whether gcc accepts >> -fno-strict-aliasing... yes checking whether gcc accepts >> -OPT:Olimit=0... no checking whether gcc accepts -Olimit 1500... no >> checking whether gcc supports ParseTuple __format__... no checking >> whether pthreads are available without options... no checking whether >> gcc accepts -Kpthread... no checking whether gcc accepts -Kthread... no >> checking whether gcc accepts -pthread... yes checking whether g++ also >> accepts flags for thread support... yes checking for ANSI C header >> files... (cached) yes checking asm/types.h usability... yes checking >> asm/types.h presence... yes checking for asm/types.h... yes checking >> conio.h usability... no checking conio.h presence... no checking for >> conio.h... no checking curses.h usability... yes checking curses.h >> presence... yes checking for curses.h... yes checking direct.h >> usability... no checking direct.h presence... no checking for >> direct.h... no checking dlfcn.h usability... yes checking dlfcn.h >> presence... yes checking for dlfcn.h... yes checking errno.h >> usability... yes checking errno.h presence... yes checking for >> errno.h... yes checking fcntl.h usability... yes checking fcntl.h >> presence... yes checking for fcntl.h... yes checking grp.h usability... >> yes checking grp.h presence... yes checking for grp.h... yes checking >> ieeefp.h usability... no checking ieeefp.h presence... no checking for >> ieeefp.h... no checking io.h usability... no checking io.h presence... >> no checking for io.h... no checking langinfo.h usability... yes >> checking langinfo.h presence... yes checking for langinfo.h... yes >> checking libintl.h usability... yes checking libintl.h presence... yes >> checking for libintl.h... yes checking ncurses.h usability... yes >> checking ncurses.h presence... yes checking for ncurses.h... yes >> checking poll.h usability... yes checking poll.h presence... yes >> checking for poll.h... yes checking process.h usability... no checking >> process.h presence... no checking for process.h... no checking >> pthread.h usability... yes checking pthread.h presence... yes checking >> for pthread.h... yes checking shadow.h usability... yes checking >> shadow.h presen
Re: How to set the socket type and the protocol of a socket using create_connection?
On 08/20/2012 11:04 AM, Guillaume Comte wrote: > > Because I work on a network emulator and I want to check biterros patterns so > I need to access the data of the packets. An dsince my test program is > written in Python, it's easier to do it in Python. You should look up scapy. http://www.secdev.org/projects/scapy/ -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: New image and color management library for Python 2+3
Am 19.08.2012 19:35, schrieb Jan Riechers: > I'm sorry for getting out of your initial question/request, but did you > try out ImageMagick before making use of FreeImage - do you even perhaps > can deliver a comparison between your project and ImageMagick (if > regular Python is used)? > > I ask cause: > Im in the process of creating a web-app which also requires image > processing and just switching from PIL (because it is unfortunately not > that quick as it should be) to ImageMagick and the speeds are much > better compared to it, but I didn't take measurements of that. Hello Jan, we decided against ImageMagick and pgmagick for several reasons. For one we were already using FreeImage in other projects (Delphi projects and through ctypes binding with FreeImagePy). Also FreeImage is much easier to install and deploy than ImageMagick, Boost and all its dependencies. We are deploying our software on several systems (Windows, Linux) and some of the Linux servers have old enterprise distributions (RHEL 4 just went out of commission). In order to support all platforms and to get reliable libraries we have to install every dependency in our own environment. The Python bindings for ImageMagick weren't that good and today they are still buggy. For example I'm not able to set the resize filter to a high quality setting like Catmull-Rom-Spline with the most recent version of pgmagick. filterType() doesn't do anything. The output image still has the same MD5 hash. ImageMagick and PIL were missing important features, too. For example both libraries don't support color management with lcms2 nor cached color transformations nor introspection of ICC profiles. They use lcms1. > Can you perhaps test your solution with ImageMagick (as it is used > widely) it would be interesting so. :) I've added some more benchmark results to the README.txt (PIL with non-standard libjpeg-turbo and pgmagick). The results are available at https://bitbucket.org/tiran/smc.freeimage Spoiler: pgmagick isn't faster and its resize filter settings don't work. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert base 10 to base 2?
On Mon, Aug 20, 2012 at 1:29 PM, Dennis Lee Bieber
wrote:
> On Mon, 20 Aug 2012 16:52:42 +0200, Jean-Michel Pichavant
> declaimed the following in
> gmane.comp.python.general:
>
>> note that the builtin bin function is not available with python ver < 2.6
>>
>> def Denary2Binary(n):
>> '''convert denary integer n to binary string bStr'''
>> bStr = ''
>> if n < 0: raise ValueError, "must be a positive integer"
>> if n == 0: return '0'
>> while n > 0:
>> bStr = str(n % 2) + bStr
>> n = n >> 1
>> return bStr
>>
>> JM
>>
>> (not my function but I can't remember who I stole from)
>
> I think I typically have done this by going through a hex
> representation.
>
> H2B_Lookup = { "0" : "", "1" : "0001",
> "2" : "0010", "3" : "0011",
> "4" : "0100", "5" : "0101",
> "6" : "0110", "7" : "0111",
> "8" : "1000", "9" : "1001",
> "A" : "1010", "B" : "1011",
> "C" : "1100", "D" : "1101",
> "D" : "1110", "F" : ""}
>
> def I2B(i):
> sgn = " "
> if i < 0:
> sgn = "-"
> i = -i
> h = ("%X" % i)
> return sgn + "".join([H2B_Lookup[c] for c in h])
>
from i2b import I2B
I2B(10)
> ' 1010'
I2B(1238)
> ' 010011100110'
I2B(-6)
> '-0110'
> --
> Wulfraed Dennis Lee Bieber AF6VN
> [email protected]://wlfraed.home.netcom.com/
>
> --
> http://mail.python.org/mailman/listinfo/python-list
This may be moving off topic, but since you encode -6 as -0110 I
thought I'd chime in on 'two's complement'
with binary number, you can represent 0 to 255 in a byte, or you can
represent numbers from 127 to -128. To get the negative you
complement each bit (0s to 1s, 1s to 0s), then add one to the result.
So:
3 -->0011
~3 -> 11100
add 1 1
result 11101
The nice thing about this representation is that arithmetic works just
fine with a mixture of negative and positive numbers.
eg 8 + (-3) > 1000
11101
gives: 0101
which is 5!
--
Joel Goldstick
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to convert base 10 to base 2?
On Mon, Aug 20, 2012 at 11:29 AM, Dennis Lee Bieber
wrote:
> I think I typically have done this by going through a hex
> representation.
>
> H2B_Lookup = { "0" : "", "1" : "0001",
> "2" : "0010", "3" : "0011",
> "4" : "0100", "5" : "0101",
> "6" : "0110", "7" : "0111",
> "8" : "1000", "9" : "1001",
> "A" : "1010", "B" : "1011",
> "C" : "1100", "D" : "1101",
> "D" : "1110", "F" : ""}
>
> def I2B(i):
> sgn = " "
> if i < 0:
> sgn = "-"
> i = -i
> h = ("%X" % i)
> return sgn + "".join([H2B_Lookup[c] for c in h])
>
from i2b import I2B
I2B(10)
> ' 1010'
I2B(1238)
> ' 010011100110'
I2B(-6)
> '-0110'
I would throw a .lstrip('0') in there to get rid of the ugly leading
zeroes (and also add a special case for i == 0).
Everybody should know the generic algorithm, though:
from itertools import chain
def convert(n, base):
digits = [chr(x) for x in chain(range(ord('0'), ord('9')+1),
range(ord('A'), ord('Z')+1))]
if not 2 <= base <= len(digits):
raise ValueError("invalid base")
output = []
sign = ""
if n < 0:
n = -n
sign = "-"
while n > 0:
n, r = divmod(n, base)
output.append(digits[r])
return sign + ''.join(reversed(output)) or '0'
--
http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On 8/20/2012 10:20 AM Walter Hurry said... On Mon, 20 Aug 2012 19:12:05 +0200, Kwpolska wrote: >Do you really need to compile python2.6? RHEL has packages for python, >and it's better s/better/sometimes easier > to use pre-compiled packages rather than compile them yourself. I concur, but FYI the version of Python with RHEL5 is 2.4. Still, OP should stick with that unless there is a pressing reason. Hence, the 2.6 install. Learn-to-trim-ly y'rs, Emile -- http://mail.python.org/mailman/listinfo/python-list
Class.__class__ magic trick help
I discovered I can do this: class A(object): pass class B(object): __class__ = A # magic b = B() isinstance(b,A) # returns True (as if B derived from A) isinstance(b,B) # also returns True I have some reasons I may want to do this (I an object with same methods as a dict but it is not derived from dict and I want isinstance(x,dict)==True to use it in place of dict in some other code). What are the problems with the magic trick above? Why does it work? massimo -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert base 10 to base 2?
On Mon, Aug 20, 2012 at 11:57 AM, Joel Goldstick wrote: > This may be moving off topic, but since you encode -6 as -0110 I > thought I'd chime in on 'two's complement' > > with binary number, you can represent 0 to 255 in a byte, or you can > represent numbers from 127 to -128. To get the negative you > complement each bit (0s to 1s, 1s to 0s), then add one to the result. > So: > 3 -->0011 > ~3 -> 11100 > add 1 1 > result 11101 > > The nice thing about this representation is that arithmetic works just > fine with a mixture of negative and positive numbers. > > eg 8 + (-3) > 1000 >11101 > gives: 0101 > which is 5! The main reason to use two's complement is when you need to encode the negative sign of the number as a bit in a format of fixed width, e.g. within a byte or word. In a string representation, unless you are specifically trying to represent computer memory, it is usually better to just use a minus sign, to be more consistent with how we usually represent numerals. Otherwise, note that complement representations are not specific to binary. For example, with decimal numbers we could use "ten's complement": individually subtract each digit from 9, and add 1 to the result. A leading digit between 5 and 9 would be considered negative. So, for example: -(042) --> 958 -(958) --> 042 958 + 042 == 000 Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: pycups
On Thu, 2012-08-09 at 04:30 -0700, loial wrote: > I am looking to monitor print jobs on linux via python. > pycups looks a possibility, but I cannot find any useful tutorial, examples > of how to use it. > Can anyone help? Modern CUPs can provide event notifications via RSS; perhaps that would work? I to would really like to find an IPP client implementation, but pycups seems to be the closest thing, doesn't do much, and is terribly documented. signature.asc Description: This is a digitally signed message part -- http://mail.python.org/mailman/listinfo/python-list
Re: Class.__class__ magic trick help
On Mon, 20 Aug 2012 11:01:36 -0700, Massimo Di Pierro wrote: > I discovered I can do this: > > class A(object): pass > class B(object): > __class__ = A # magic Why do you think that's magic? > b = B() > isinstance(b,A) # returns True (as if B derived from A) b.__class__ is A, so naturally isinstance(b, A) will return True. > isinstance(b,B) # also returns True type(b) is B, so naturally isinstance(b, B) will return True. > I have some reasons I may want to do this (I an object with same methods > as a dict but it is not derived from dict and I want > isinstance(x,dict)==True to use it in place of dict in some other code). Be aware that some parts of Python will insist on real dicts, not just subclasses or fake dicts. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On Mon, 20 Aug 2012 11:02:25 -0700, Emile van Sebille wrote: > On 8/20/2012 10:20 AM Walter Hurry said... >> On Mon, 20 Aug 2012 19:12:05 +0200, Kwpolska wrote: > > > >>> >Do you really need to compile python2.6? RHEL has packages for >>> >python, >>> >and it's better > > s/better/sometimes easier > >>> > to use pre-compiled packages rather than compile them yourself. > > >> I concur, but FYI the version of Python with RHEL5 is 2.4. Still, OP >> should stick with that unless there is a pressing reason. > > Hence, the 2.6 install. First, sorry for my omission to trim. Second, the reason for recommending that OP stick to the Red Hat provided version (unless there is a pressing reason) is the question of the already-paid-for Red Hat support. And for that matter, if OP is forced to a later Python 2 version than 2.4, why not 2.7.3? -- http://mail.python.org/mailman/listinfo/python-list
Re: Class.__class__ magic trick help
On Mon, Aug 20, 2012 at 12:01 PM, Massimo Di Pierro wrote: > I discovered I can do this: > > class A(object): pass > class B(object): > __class__ = A # magic > > b = B() > isinstance(b,A) # returns True (as if B derived from A) > isinstance(b,B) # also returns True > > I have some reasons I may want to do this (I an object with same > methods as a dict but it is not derived from dict and I want > isinstance(x,dict)==True to use it in place of dict in some other > code). > > What are the problems with the magic trick above? Why does it work? Normally with __class__ assignment, you would assign to the __class__ attribute of the *instance*, not the class declaration. This actually changes the class of the object, and so isinstance(b, B) would no longer return True. I've never heard of assigning it in the class declaration, and as far as I know, this behavior isn't documented anywhere. I expect that what's happening here is that Python is not actually updating the class of the instance, but that A is merely assigned to the "__class__" attribute in the class dict, and that isinstance is somehow (perhaps accidentally) finding this. So I think this is probably a bug, and I would not rely on it to work correctly in all cases. In any event, the use case that you're looking for is usually accomplished using abstract base classes. Instead of "isinstance(x, dict)", you should use "isinstance(x, collections.MutableMapping)", and then inherit your class from or register it with the MutableMapping ABC. -- http://mail.python.org/mailman/listinfo/python-list
Re: Abuse of Big Oh notation
By chance and luckily, first attempt.
IDLE, Windows 7.0 Pro 32, Pentium Dual Core 2.6, RAM 2 Go
Py 3.2.3
>>> timeit.repeat("('€'*100+'€'*100).replace('€', 'œ')")
[1.6939567134893707, 1.672874290786993, 1.6761219212298073]
Py 3.3.0b2
>>> timeit.repeat("('€'*100+'€'*100).replace('€', 'œ')")
[7.924470733910917, 7.8554985620787345, 7.878623849091914]
Console
c:\python32\python -m timeit "('€'*100+'€'*100).replace('€'
, 'œ')"
100 loops, best of 3: 1.48 usec per loop
c:\python33\python -m timeit "('€'*100+'€'*100).replace('€'
, 'œ')"
10 loops, best of 3: 7.62 usec per loop
Note
The used characters are not members of the latin-1 coding
scheme (btw an *unusable* coding).
They are however charaters in cp1252 and mac-roman.
jmf
--
http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On 8/20/2012 11:37 AM Walter Hurry said... On Mon, 20 Aug 2012 11:02:25 -0700, Emile van Sebille wrote: On 8/20/2012 10:20 AM Walter Hurry said... I concur, but FYI the version of Python with RHEL5 is 2.4. Still, OP should stick with that unless there is a pressing reason. Hence, the 2.6 install. First, sorry for my omission to trim. Second, the reason for recommending that OP stick to the Red Hat provided version (unless there is a pressing reason) is the question of the already-paid-for Red Hat support. Generally, when you compile from source the binaries will install to /usr/local/bin and not be in conflict with RH's install version. And for that matter, if OP is forced to a later Python 2 version than 2.4, why not 2.7.3? Package dependencies. If the OP intends to install a package that doesn't support other than 2.6, you install 2.6. Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: Abuse of Big Oh notation
Ian Kelly writes: > The difference between the two is that the former is bounded by a > constant that is fundamental to the algorithm at hand,... S is > clearly bounded by the constraints of actual shoes, so we can safely > treat S as a constant and call it O(N). Thanks, that is a good explain of what I was trying to get at. One quibble is in the parsing example, the constant is inherent in the distribution of input data one expects to normally encounter, rather than in the algorithm itself. It's sort of like saying dictionary access (based on hashing) is O(1), based on the variety of input data that is normally used. There is such a thing as pathological (e.g. malicious) input data that causes a lot of hash collisions, making O(n) access in the size of the dictionary. I suppose abnormal input should also be taken into account in examples involving parsing if one parses potentially hostile data. -- http://mail.python.org/mailman/listinfo/python-list
Re: Class.__class__ magic trick help
The fact is this works: >>> class B(object): ...__class__ = dict >>> b=B() but this does not >>> class B(object): ...def __init__(self): ...self.__class__ = dict >>> b=B() Traceback (most recent call last): File "", line 1, in File "", line 3, in __init__ TypeError: __class__ assignment: only for heap types On Aug 20, 1:39 pm, Ian Kelly wrote: > On Mon, Aug 20, 2012 at 12:01 PM, Massimo Di Pierro > > wrote: > > I discovered I can do this: > > > class A(object): pass > > class B(object): > > __class__ = A # magic > > > b = B() > > isinstance(b,A) # returns True (as if B derived from A) > > isinstance(b,B) # also returns True > > > I have some reasons I may want to do this (I an object with same > > methods as a dict but it is not derived from dict and I want > > isinstance(x,dict)==True to use it in place of dict in some other > > code). > > > What are the problems with the magic trick above? Why does it work? > > Normally with __class__ assignment, you would assign to the __class__ > attribute of the *instance*, not the class declaration. This actually > changes the class of the object, and so isinstance(b, B) would no > longer return True. > > I've never heard of assigning it in the class declaration, and as far > as I know, this behavior isn't documented anywhere. I expect that > what's happening here is that Python is not actually updating the > class of the instance, but that A is merely assigned to the > "__class__" attribute in the class dict, and that isinstance is > somehow (perhaps accidentally) finding this. So I think this is > probably a bug, and I would not rely on it to work correctly in all > cases. > > In any event, the use case that you're looking for is usually > accomplished using abstract base classes. Instead of "isinstance(x, > dict)", you should use "isinstance(x, collections.MutableMapping)", > and then inherit your class from or register it with the > MutableMapping ABC. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
kj writes: > This means that no library code can ever count on, for example, > being able to reliably find the path to the file that contains the > definition of __main__. That's a weakness, IMO. On Unix based systems there is no reliable way to find out this information. So how could Python reliably supply this? -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: A difficulty with lists
On Monday, August 6, 2012 12:50:13 PM UTC-7, Mok-Kong Shen wrote:
> I ran the following code:
>
>
>
> def xx(nlist):
>
>print("begin: ",nlist)
>
>nlist+=[999]
>
>print("middle:",nlist)
>
>nlist=nlist[:-1]
>
>print("final: ",nlist)
>
>
>
> u=[1,2,3,4]
>
> print(u)
>
> xx(u)
>
> print(u)
>
>
>
> and obtained the following result:
>
>
>
> [1, 2, 3, 4]
>
> begin: [1, 2, 3, 4]
>
> middle: [1, 2, 3, 4, 999]
>
> final: [1, 2, 3, 4]
>
> [1, 2, 3, 4, 999]
>
>
>
> As beginner I couldn't understand why the last line wasn't [1, 2, 3, 4].
>
> Could someone kindly help?
>
>
>
> M. K. Shen
When you pass a list (mutable object) to a function, the pointer to the list is
passed to the function and the corresponding argument points to the same memory
location as the pointer passed in. So in this case, nlist points to the same
memory location which u points to when xx is called, i.e. nlist and u points
to same memory location which contains [1,2,3,4].
nlist += [999] is equivalent to nlist.extend([999]). This statement adds the
argument list to the original list, i.e. the memory location pointed by nlist
and u now contains [1,2,3,4,999]. So, print(u) after calling xx will print
[1,2,3,4,999].
nlist += [999] is not the same as nlist = nlist + [999]. In the later case,
nlist + [999] will create a new memory location containing the two lists
combined and rebind nlist to the new location, i.e. nlist points to a new
memory location that has [1,2,3,4,999]. So if nlist = nlist +[999] is used, the
original memory location containing [1,2,3,4] is untouched, and print(u) after
calling xx will print [1,2,3,4]
--
http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On Mon, 20 Aug 2012 12:19:23 -0700, Emile van Sebille wrote: > Package dependencies. If the OP intends to install a package that > doesn't support other than 2.6, you install 2.6. It would be a pretty poor third party package which specified Python 2.6 exactly, rather than (say) "Python 2.6 or later, but not Python 3" -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I display unicode value stored in a string variable using ord()
"Blind Anagram" writes: > This is an average slowdown by a factor of close to 2.3 on 3.3 when > compared with 3.2. > > I am not posting this to perpetuate this thread but simply to ask > whether, as you suggest, I should report this as a possible problem with > the beta? Being a beta release, is it certain that this release has been compiled with the same optimization level as 3.2? -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On 8/20/2012 1:55 PM Walter Hurry said... On Mon, 20 Aug 2012 12:19:23 -0700, Emile van Sebille wrote: Package dependencies. If the OP intends to install a package that doesn't support other than 2.6, you install 2.6. It would be a pretty poor third party package which specified Python 2.6 exactly, rather than (say) "Python 2.6 or later, but not Python 3" It doesn't need to be a poorly supported third party package to require a non-current version of python -- just something as simple as an up and running application. Suppose you're migrating an application to new hardware. To make it interesting, assume it's a 10 year old zope application. It's likely that to minimize effort you'll gather (assuming you didn't save your sources - you do install from source, right?) and install the versions prescribed. Of course, if you're comfortable upgrading to the latest release then then, by all means, do so. For me, python is used for for dozens of rather significant one-offs that I prefer not to upgrade. Why mess with a working app. Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: Abuse of Big Oh notation
Paul Rubin於 2012年8月21日星期二UTC+8上午3時29分12秒寫道: > Ian Kelly writes: > > > The difference between the two is that the former is bounded by a > > > constant that is fundamental to the algorithm at hand,... S is > > > clearly bounded by the constraints of actual shoes, so we can safely > > > treat S as a constant and call it O(N). > > > > Thanks, that is a good explain of what I was trying to get at. One > > quibble is in the parsing example, the constant is inherent in the > > distribution of input data one expects to normally encounter, rather > > than in the algorithm itself. It's sort of like saying dictionary > > access (based on hashing) is O(1), based on the variety of input data > > that is normally used. There is such a thing as pathological > > (e.g. malicious) input data that causes a lot of hash collisions, making > > O(n) access in the size of the dictionary. > > > > I suppose abnormal input should also be taken into account in examples > > involving parsing if one parses potentially hostile data. OK, the hash key function has to be seeded with some randomization in the begining of a hash table from some data independent factors. Also for those items hashed to the same key with a length >=16 I think an insertion sort is good in soring a sorted list of items hashed to the same key of a length 16 to 256 or even larger which indicates the hash function should be changed from time to time in the occasions of resizing the hash table when the table is under a lot operations of item inserstions and deletions which are much greater than the number of item searches in the same period. -- http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On 20Aug2012 12:19, Emile van Sebille wrote: | On 8/20/2012 11:37 AM Walter Hurry said... | > On Mon, 20 Aug 2012 11:02:25 -0700, Emile van Sebille wrote: | >> On 8/20/2012 10:20 AM Walter Hurry said... | >>> I concur, but FYI the version of Python with RHEL5 is 2.4. Still, OP | >>> should stick with that unless there is a pressing reason. | >> | >> Hence, the 2.6 install. | > | > First, sorry for my omission to trim. | > | > Second, the reason for recommending that OP stick to the Red Hat provided | > version (unless there is a pressing reason) is the question of the | > already-paid-for Red Hat support. | | Generally, when you compile from source the binaries will install to | /usr/local/bin and not be in conflict with RH's install version. I was going to chime in with this anyway had the thread said nothing; I strongly prefer to specify --prefix explicitly with configure. My personal habit to to build with (adjust to match): --prefix=/usr/local/python-2.6.4 and put some symlinks in /usr/local/bin afterwards (python2.6, etc). That way one doesn't tread on the system Python (after all the OS vendor distro is also a collection of packages with coordinated versions) and one can easily put in another python beside it. | > And for that matter, if OP is forced to a later Python 2 version than | > 2.4, why not 2.7.3? | | Package dependencies. If the OP intends to install a package that | doesn't support other than 2.6, you install 2.6. Indeed. And this is a strong reason to keep out of the vendor's /usr filesystem space, also. Cheers, -- Cameron Simpson -- http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On Mon, Aug 20, 2012 at 10:25 PM, Cameron Simpson wrote: > I was going to chime in with this anyway had the thread said nothing; I > strongly prefer to specify --prefix explicitly with configure. > > My personal habit to to build with (adjust to match): > > --prefix=/usr/local/python-2.6.4 > > and put some symlinks in /usr/local/bin afterwards (python2.6, etc). > > That way one doesn't tread on the system Python (after all the OS vendor > distro is also a collection of packages with coordinated versions) > and one can easily put in another python beside it. +1. I like to build a bunch of representative python versions, and test code on some subset of them - often all of them. I usually do 2.5, 2.6, 2.7, 3.0, 3.1, 3.2 and 3.3, but sometimes I get more specific than that. I'll also do a couple of jython's and pypy's normally. It's remarkable how revealing such a simple thing can be for portability. -- http://mail.python.org/mailman/listinfo/python-list
[email protected]
> > I also tend to blame M$ (Outlook and variants) for this tendency to > > quote everything and top-post -- Outlook makes it almost impossible > > to do a trim&interleave response style. > > I that Outlook & Co are guilty. That and the fact that few people even > think about this. Nonsense, I post only from Outlook. You can do it and it is not hard. It is just requires a little effort. Top posting makes more sense in a corporate setting for a couple reasons. Seeing the exact email trail rather than what someone considers "relevant" context can be very useful. Not to mention that frequently corporate email is more like slow instant messaging; I need less context (e.g. conversation history) and get all the information I need from what the sender is writing. I find inline (and to a lesser extent bottom) posting to be a mixed bag. Some people do it well and it is easy to read, but there are others who do not make it as easy (for me) to read. Lots of posts are not trimmed enough, or trimmed too much. I am not advocating top-posting. I just think that different styles are good for different cases/environments. Blame the person, not the application for having poor habits and/or being inconsiderate of the community. :) Ramit P.S. Ironically, I do blame Outlook for making it hard (impossible?) to find/see the 80 char boundary. This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
RE: [ANNC] pybotwar-0.8
>Look you are the only person complaining about top-posting. >GMail uses top-posting by default. >I can't help it if you feel irritated by it. He is most certainly not the only person to feel irritated nor even the only person who has requested you not to top post. He does happen to be the most persistent though. Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: Abuse of Big Oh notation
Paul Rubin於 2012年8月21日星期二UTC+8上午3時29分12秒寫道: > Ian Kelly writes: > > > The difference between the two is that the former is bounded by a > > > constant that is fundamental to the algorithm at hand,... S is > > > clearly bounded by the constraints of actual shoes, so we can safely > > > treat S as a constant and call it O(N). > > > > Thanks, that is a good explain of what I was trying to get at. One > > quibble is in the parsing example, the constant is inherent in the > > distribution of input data one expects to normally encounter, rather > > than in the algorithm itself. It's sort of like saying dictionary > > access (based on hashing) is O(1), based on the variety of input data > > that is normally used. There is such a thing as pathological > > (e.g. malicious) input data that causes a lot of hash collisions, making > > O(n) access in the size of the dictionary. > > > > I suppose abnormal input should also be taken into account in examples > > involving parsing if one parses potentially hostile data. OK, the hash key function has to be seeded with some randomization in the creation of a hash table from some data independent factors. Also for those items hashed to the same key with a length >=16 I think an insertion sort and a heap sort are good in storing a sorted list of items hashed to the same key of a length 16 to 256 or even larger which indicates the hash function should be changed from time to time in the occasions of resizing the hash table when the table is under a lot operations of item insertions and deletions which are operated much frequently than the number of item searches in the same period. -- http://mail.python.org/mailman/listinfo/python-list
RE: [ANNC] pybotwar-0.8
> I'll be using Google Groups (hopefully it won't top-post by default) to post > stuff. Thanks for not top-posting. Even if it is the default, it is not difficult to change. :) Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: Does Polymorphism mean python can create object?
On Tue, Aug 21, 2012 at 12:01 AM, Levi Nie wrote: > Does Polymorphism mean python can create object? No. This isn't D&D. Polymorphism has a distinct meaning in computer science, one which you would've found in less time searching Wikipedia than asking this question here. -- http://mail.python.org/mailman/listinfo/python-list
Re: Abuse of Big Oh notation
In article , [email protected] wrote: > Note > The used characters are not members of the latin-1 coding > scheme (btw an *unusable* coding). > They are however charaters in cp1252 and mac-roman. mac-roman is an obsolete encoding that was used in MacOS 9 and MacOS Classic systems of previous decades. Except in a very small and shrinking number of legacy applications, it isn't used in modern systems and hasn't been widely used for a long time. MacOS X systems generally use standard Unicode encodings, usually UTF-8, for external representations. Forget about mac-roman; it is not relevant. -- Ned Deily, [email protected] -- http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
Nobody: Maybe. On Unix, it's possible that the current directory no longer has a pathname. Its also possible that you do not have permission to successfully call getcwd. One example of this I have experienced is the OS X sandbox where you can run Python starting in a directory where you have only limited permissions. getcwd works by calling readdir and lstat and looping up from the current directory to the root to build the whole path so will break without read permissions on directories: http://www.opensource.apple.com/source/Libc/Libc-763.13/gen/FreeBSD/getcwd.c Neil -- http://mail.python.org/mailman/listinfo/python-list
[email protected]
On Mon, 20 Aug 2012 22:49:24 +, Prasad, Ramit wrote: >> > I also tend to blame M$ (Outlook and variants) for this tendency to >> > quote everything and top-post -- Outlook makes it almost impossible >> > to do a trim&interleave response style. >> >> I that Outlook & Co are guilty. That and the fact that few people even >> think about this. > > Nonsense, I post only from Outlook. You can do it and it is not hard. It > is just requires a little effort. > > Top posting makes more sense in a corporate setting for a couple > reasons. Seeing the exact email trail rather than what someone considers > "relevant" context can be very useful. That's what your email archive, and the threading information in the email headers, is for. When people used to correspond by paper mail, they did not photocopy the entire past correspondence and staple it to the back of their letter. And then the person responding didn't photocopy the photocopies and post them back with his response. If somebody did, that would be stupid -- did he think the sender posted the originals and didn't keep a copy? If there was a business requirement to make copies of copies of copies, people would have done it. But there wasn't, and it was stupid and costly and so they didn't. With email, it's less costly, but it's equally stupid. Email programs reduce the cost of making and posting those photocopies to essentially zero, at least zero for the person pressing Send. It might be almost free for the sender, but it's still stupid. Nobody looks at those deep email trails. When you want to find out the order of correspondence, you sort your mail folder by Thread or by Date and look at it there, not by trying to interpret the copies of copies of copies of past discussions. Nobody uses them. They just bulk up email and get in the way of communication and make searching for relevant emails harder. I've had to dig through email archives for legal purposes, looking for evidence in legal cases, and having to read past copies of copies of copies of copies (down to ten or twelve levels deep!!!) makes the process much, much, much harder than it should be. Top posting in and of itself is not always bad. But the practice of leaving copies of copies of copies in the body of the email is beyond stupid. If they were *attachments* that could be ignored when printed, that would be *almost* sane, but putting them in the body of the email is insane. > Not to mention that frequently > corporate email is more like slow instant messaging; I need less context > (e.g. conversation history) and get all the information I need from > what the sender is writing. In my experience, if you ask a question in corporate environments by email, you're lucky to get an answer within a day. Slow indeed. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: How to convert base 10 to base 2?
Ian Kelly writes: > Everybody should know the generic algorithm, though: > from itertools import chain ... For n>0, assuming you just want the converted digits and not a string. String conversion and minus sign for n<0 left as exercise. Note this returns a generator that you can convert to a list with list(...). def convert(n, base): a,b = divmod(n,base) if a > 0: for e in convert(a,base): yield e yield b -- http://mail.python.org/mailman/listinfo/python-list
Re: New internal string format in 3.3
On 08/20/2012 07:17 AM, Roy Smith wrote: > In article , > Michael Torrie wrote: > >> Python generally tries to follow unicode >> encoding rules to the letter. Thus if a piece of text cannot be >> represented in the character set of the terminal, then Python will >> properly err out. Other languages you have tried, likely fudge it >> somehow. > > And if you want the "fudge it somehow" behavior (which is often very > useful!), there's always http://pypi.python.org/pypi/Unidecode/ Sweet tip, thanks! I often want to process text that has smart quotes, emdashes, etc, and convert them to plain old ascii quotes, dashes, ticks, etc. This will do that for me without resorting to a bunch of regexes. Bravo. -- http://mail.python.org/mailman/listinfo/python-list
Re: Class.__class__ magic trick help
Consider this code:
class SlowStorage(dict):
def __getattr__(self,key):
return self[key]
def __setattr__(self,key):
self[key]=value
class FastStorage(dict):
def __init__(self, __d__=None, **kwargs):
self.update(__d__,**kwargs)
def __getitem__(self,key):
return self.__dict__.get(key,None)
def __setitem__(self,key,value):
self.__dict__[key] = value
def __delitem__(self,key):
delattr(self,key)
def __copy__(self):
return Storage(self)
def __nonzero__(self):
return len(self.__dict__)>0
def pop(self,key,default=None):
if key in self:
default = getattr(self,key)
delattr(self,key)
return default
def clear(self):
self.__dict__.clear()
def __repr__(self):
return repr(self.__dict__)
def keys(self):
return self.__dict__.keys()
def values(self):
return self.__dict__.values()
def items(self):
return self.__dict__.items()
def iterkeys(self):
return self.__dict__.iterkeys()
def itervalues(self):
return self.__dict__.itervalues()
def iteritems(self):
return self.__dict__.iteritems()
def viewkeys(self):
return self.__dict__.viewkeys()
def viewvalues(self):
return self.__dict__.viewvalues()
def viewitems(self):
return self.__dict__.viewitems()
def fromkeys(self,S,v=None):
return self.__dict__.fromkeys(S,v)
def setdefault(self, key, default=None):
try:
return getattr(self,key)
except AttributeError:
setattr(self,key,default)
return default
def clear(self):
self.__dict__.clear()
def len(self):
return len(self.__dict__)
def __iter__(self):
return self.__dict__.__iter__()
def has_key(self,key):
return key in self.__dict__
def __contains__(self,key):
return key in self.__dict__
def update(self,__d__=None,**kwargs):
if __d__:
for key in __d__:
kwargs[key] = __d__[key]
self.__dict__.update(**kwargs)
def get(self,key,default=None):
return getattr(self,key) if key in self else default
>>> s=SlowStorage()
>>> a.x=1 ### (1)
>>> a.x### (2)
1 # ok
>>> isinstance(a,dict)
True # ok
>>> print dict(a)
{'x':1} # ok (3)
>>> s=FastStorage()
>>> a.x=1 ### (4)
>>> a.x### (5)
1 # ok
>>> isinstance(a,dict)
True # ok
>>> print dict(a)
{} # not ok (6)
Lines (4) and (5) are about 10x faster then lines (1) and (2). I like
FastStorage better but while (3) behaves ok, (6) does not behave as I
want.
I intuitively understand why FastStorage is cannot cast into dict
properly.
What I do not know is how to make it do the casting properly without
losing the 10x speedup of FastStorage over SlowStorage.
Any idea?
--
http://mail.python.org/mailman/listinfo/python-list
Re: Why doesn't Python remember the initial directory?
alex23 writes: > Oh my god, how DARE people with EXPERIENCE in a language challenge the > PRECONCEPTIONS of an AMATEUR!!! HOW DARE THEY?!?! +1 QOTW :) -- http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On 8/20/2012 2:50 PM, Emile van Sebille wrote: > On 8/20/2012 1:55 PM Walter Hurry said... >> On Mon, 20 Aug 2012 12:19:23 -0700, Emile van Sebille wrote: >> >>> Package dependencies. If the OP intends to install a package that >>> doesn't support other than 2.6, you install 2.6. >> >> It would be a pretty poor third party package which specified Python 2.6 >> exactly, rather than (say) "Python 2.6 or later, but not Python 3" After a thread of clueless replies, it's clear that nobody responding actually read the build log. Here's the problem: Failed to find the necessary bits to build these modules: bsddb185 dl imageop sunaudiodev What's wrong is that the Python 2.6 build script is looking for some antiquated packages that aren't in a current RHEL. Those need to be turned off. This is a known problem (see http://pythonstarter.blogspot.com/2010/08/bsddb185-sunaudiodev-python-26-ubuntu.html) but, unfortunately, the site with the patch for it (http://www.lysium.de/sw/python2.6-disable-old-modules.patch) is no longer in existence. But someone archived it on Google Code, at http://code.google.com/p/google-earth-enterprise-compliance/source/browse/trunk/googleclient/geo/earth_enterprise/src/third_party/python/python2.6-disable-old-modules.patch so if you apply that patch to the setup.py file for Python 2.6, that ought to help. You might be better off building Python 2.7, but you asked about 2.6. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
John Nagle wrote: > On 8/20/2012 2:50 PM, Emile van Sebille wrote: >> On 8/20/2012 1:55 PM Walter Hurry said... >>> On Mon, 20 Aug 2012 12:19:23 -0700, Emile van Sebille wrote: >>> Package dependencies. If the OP intends to install a package that doesn't support other than 2.6, you install 2.6. >>> >>> It would be a pretty poor third party package which specified Python 2.6 >>> exactly, rather than (say) "Python 2.6 or later, but not Python 3" > > After a thread of clueless replies, it's clear that nobody > responding actually read the build log. Here's the problem: There are a lot of clueless statements on websites around the world. I'll just quote the one significant comment on the lysium.de page: """ There's actually no need to apply your patch to setup.py. Python complains about not being able to build those modules, but it will still build and install just fine without them. #6 Alexander Fairley on 2009-01-19 01:43 """ which is unfortunately burried under an avalanche of "satisfied customer" replies. Alexander, you're my hero ;) > > Failed to find the necessary bits to build these modules: > bsddb185 > dl > imageop > sunaudiodev > > What's wrong is that the Python 2.6 build script is looking for > some antiquated packages that aren't in a current RHEL. Those > need to be turned off. > > This is a known problem (see > http://pythonstarter.blogspot.com/2010/08/bsddb185-sunaudiodev-python-26- ubuntu.html) > but, unfortunately, the site with the patch for it > (http://www.lysium.de/sw/python2.6-disable-old-modules.patch) > is no longer in existence. > > But someone archived it on Google Code, at > > http://code.google.com/p/google-earth-enterprise- compliance/source/browse/trunk/googleclient/geo/earth_enterprise/src/third_party/python/python2.6- disable-old-modules.patch > > so if you apply that patch to the setup.py file for Python 2.6, that > ought to help. That patch prevents setup.py from adding a few names of rarely needed/available modules to the list of missing modules. That's snakeoil. OP: You can safely ignore the error message, the patch has no real-world effect. -- http://mail.python.org/mailman/listinfo/python-list
Re: Top-posting &c. (was Re: [ANNC] pybotwar-0.8)
On 2012/08/17 12:42 AM, Madison May wrote: As a lurker, I agree completely with Chris's sentiments. I too, but I'd prefer something top-posted than have to skip through 38 pages of quoted e-mail to get to a (generally) 1 liner at the bottom. -- Regards Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: python 6 compilation failure on RHEL
On 8/20/2012 9:34 PM John Nagle said... After a thread of clueless replies, s/clueless/unread Emile -- http://mail.python.org/mailman/listinfo/python-list
