Re: Over 30 types of variables available in python ?

2013-01-07 Thread chaouche yacine
Thanks for all your comments. It appears to me that there is a slight confusion 
between types and classes then, plus other entities (protocols ?)

So my question is : is there a notion of type in python, like in other 
languages  (integers, booleans, floats, strings, characters (in c)) ? if so, 
can you give a list of the available types ? 


The documentation (http://docs.python.org/2/library/stdtypes.html) states The 
principal built-in types are numerics, sequences, mappings, files, classes,
instances and exceptions.







 From: Terry Reedy tjre...@udel.edu
To: python-list@python.org 
Sent: Monday, January 7, 2013 1:45 AM
Subject: Re: Over 30 types of variables available in python ?
 
On 1/6/2013 6:12 PM, chaouche yacine wrote:
 
 booleans
 ints, floats, longs, complexes
 strings, unicode strings
 lists, tuples, dictionaries, dictionary views, sets, frozensets,
 buffers, bytearrays, slices
 functions, methods, code objects,modules,classes, instances, types,
 nulls (there is exactly one object of type Null which is None),
 tracebacks, frames
 generators, iterators, xranges,
 files,
 memoryviews,
 context managers,
 
 These are all listed in this page
 http://docs.python.org/2/library/stdtypes.html as built-in types.

They would better be called classes. Every thing is Python is an instance of a 
class. 'Iterator' and 'context manager' are protocols that multiple classes can 
follow, not classes themselves.

 Am I
 getting anything wrong here ? I'm a bit confused about it. I have never
 seen so many types in the few programming languages I saw.

C has up to 8 integer types, Python 3 just 1. Most of the above are structures 
in C, which may or may not by typedef-ed, or classes in C++. If you counted all 
the structures and classes that come with C or C++, you would find a comparable 
number.

C stdlib has a pointer to file structure type, which is equivalent to Python's 
file class. It is true that C does not come with hashed arrays (sets) and 
hashed associative arrays (dicts), but they are often needed. So C programmers 
either reinvent the wheel or include a third-party library. C also has frame 
structure, but they are normally hidden. C programmers do not have easy direct 
access. However, virus writers learn to work with them ;-(.

-- Terry Jan Reedy

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


Re: os.path.realpath(path) bug on win7 ?

2013-01-07 Thread iMath
在 2013年1月7日星期一UTC+8上午7时40分06秒,Victor Stinner写道:
 It looks like the following issue:
 
 http://bugs.python.org/issue14094
 
 Victor
 
 Le 6 janv. 2013 07:59, iMath 22815...@qq.com a écrit :
 
 
 
 
 os.path.realpath(path)  bug on win7 ?
 
 Temp.link is a Symbolic link
 Its target location is C:\test\test1
 But 
  os.path.realpath(r'C:\Users\SAMSUNG\Temp.link\test2')
 'C:\\Users\\SAMSUNG\\Temp.link\\test2'
 
 
 I thought the return value should be ' C:\\test\\test1\\test2'
 
 Is it a bug ? anyone can clear it to me ?
 
 
 --
 
 http://mail.python.org/mailman/listinfo/python-list
perhaps it is
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to detect the character encoding in a web page ?

2013-01-07 Thread iMath
在 2012年12月24日星期一UTC+8上午8时34分47秒,iMath写道:
 how to detect the character encoding  in a web page ?
 
 such as this page 
 
 
 
 http://python.org/

up to now , maybe chadet is the only way to let python automatically do it .
-- 
http://mail.python.org/mailman/listinfo/python-list


INSTRUCTOR SOLUTIONS MANUAL :: Design of Reinforced Concrete, 8th Ed by McCormac, Brown

2013-01-07 Thread ronaldmanualsea
Here are instructor's solutions manuals to the scientific textbooks in PDF 
format. They cover solutions to all problems. If you need any, let me know its 
title, edition and author. 
If your title is not listed here don't worry because it is a list of some.. 
NOTE: This service is NOT free, and Don't reply here, 
instead send an email to: 
ronaldmanualsea( at )gmail(dot)com.


INSTRUCTOR SOLUTIONS MANUAL :: Intermediate Accounting - IFRS Edition Vol.1 by 
Kieso, Weygandt, Warfield
INSTRUCTOR SOLUTIONS MANUAL :: Intermediate Accounting 12th ed by Kieso
INSTRUCTOR SOLUTIONS MANUAL :: Intermediate Accounting 13 ed by Kieso
INSTRUCTOR SOLUTIONS MANUAL :: Intermediate Accounting Kieso 12th ed
INSTRUCTOR SOLUTIONS MANUAL :: INTERMEDIATE ACCOUNTING, 6th Edition, by 
Spiceland, Sepe
INSTRUCTOR SOLUTIONS MANUAL :: Intermediate Algebra - Concepts  Applications 
8th Ed by Bittinger, Ellenbogen
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Accounting 3rd Ed by Marriott, 
Mellett
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Algorithms, 2nd Ed by Cormen, 
Leiserson 
INSTRUCTOR SOLUTIONS MANUAL :: Introduction To Analysis (3rdEd) -by William Wade
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Applied Modern Physics by Henok 
Abebe
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Chemical Engineering 
Thermodynamics (7th Ed., Smith  Van Ness)
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Commutative Algebra by M. F. 
Atiyah
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Digital Signal Processing (in 
Serbian) by Lj. Milic and Z. Dobrosavljevic
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Econometrics (2nd ed., James H. 
Stock  Mark W. Watson)
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Electric Circuits 7th Edition by 
Dorf, Svaboda
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Electric Circuits, 6E, Dorf
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Electrodynamics (3rd Ed., David 
J. Griffiths)
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Elementary Particles 2nd Ed by 
David Griffiths
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Environmental Engineering and 
Science (3rd Ed., Gilbert M. Masters  Wendell P. Ela)
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Environmental Engineering and 
Science, Edition 2, Masters
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Ergonomics 2E by Robert Bridger
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Fluid Mechanics ( 7 E., Robert 
Fox, Alan McDonald  Philip )
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Fluid Mechanics (6E., Robert 
Fox, Alan McDonald  Philip)
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to fluid mechanics 5th edition by 
Alan T. McDonald, Robert W Fox
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Graph Theory 2E - West
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Heat Transfer by Vedat S. 
Arpaci, Ahmet Selamet, Shu-Hsin Kao
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Java Programming, Comprehensive 
Version 7th Ed by  Liang
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Linear Algebra, 3rd Ed., by 
Gilbert Strang
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Management Accounting, 14 ED by 
Horngren, Schatzberg 
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Materials Science for Engineers 
(6th Ed., Shackelford)
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Materials Science for Engineers 
7th E by Shackelford
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Mathematical Statistics (6th 
Ed., Hogg, Craig  McKean)
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Mechatronics and Measurements 
Systems 2nd Ed by Alciatore, Histand
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Nuclear And Particle Physics 2nd 
E by Bromberg, Das, Ferbel
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Operations Research - 7th ed by 
Frederick Hillier, Gerald Lieberman
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Probability 2nd Ed by Bertsekas 
and Tsitsiklis
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Probability by Dimitri P. 
Bertsekas and John N. Tsitsiklis
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Probability by Grinstead, Snell
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Quantum Mechanics (2nd Ed., 
David J. Griffiths)
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Quantum Mechanics 1st edition 
(1995) by David J. Griffiths
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Queueing Theory 2nd Edition by 
R.B. Cooper
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Scientific Computation and 
Programming, 1st Edition by Daniel Kaplan
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Signal Processing by S. J. 
Orfanidis
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Signal Processing by Sophocles 
J. Orfanidis
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Solid State Physics 8th Ed by 
Kittel  Charles
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Statistical Physics by Kerson 
Huang
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to Statistical Quality Control (5th 
Ed., Douglas C. Montgomery)
INSTRUCTOR SOLUTIONS MANUAL :: Introduction to the Theory 

Re: regular expression : the dollar sign ($) work with re.match() or re.search() ?

2013-01-07 Thread iMath
在 2012年9月26日星期三UTC+8下午3时38分50秒,iMath写道:
 I only know  the dollar sign ($) will match a pattern from the
 
 end of a string,but which method does it work with ,re.match() or re.search() 
  ?

I thought re.match('h.$', 'hbxihi') will match ‘hi’ ,but it does not .so why ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyodbc utf-8

2013-01-07 Thread Markus Christen
When i look at my output on my webpage, i can see this:
W\xe4denswil
but it have to be this:
Wädenswil
you know now what i can see exactly... im using django and they told me its a 
python problem with utf-8. when i turn off debug, i cant see the page, it give 
me an error 500.
the text Danke für die... on the bottom of my page is displayed correct. the 
error comes only when an umlaut is to post, out of the raw.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Over 30 types of variables available in python ?

2013-01-07 Thread Steven D'Aprano
On Mon, 07 Jan 2013 00:53:26 -0800, chaouche yacine wrote:

 Thanks for all your comments. It appears to me that there is a slight
 confusion between types and classes then, plus other entities (protocols
 ?)


In Python 3, types and classes are synonyms. They mean the same thing.

In Python 2, there is a very subtle difference, due to the existence of 
old style or classic classes, for backward compatibility, which are 
not identical to new style classes, also known as types. But they are a 
kind of type -- although there are some differences, you can consider 
them to be the same sort of thing.


 So my question is : is there a notion of type in python, like in other
 languages  (integers, booleans, floats, strings, characters (in c)) ? if
 so, can you give a list of the available types ?

Yes, and no.

Yes, there is a notation of type in Python which is exactly the same sort 
of notation of type in other languages, such as C. The difference between 
C and Python is not in the notation of type, but in the notation of 
variable or name.

In C, *variables* have a type. If you declare a variable x to be a float, 
then three things happen:

* the C compiler creates a fixed memory location and calls it x;

* the C compiler interprets the *value* of that memory location (which is 
actually just a bunch of bytes) as a float;

* the C compiler will only ever place values into that memory location if 
it thinks that the value is a float, or compatible with a float.

Because all values are bunches of bytes, you can (with a bit of effort) 
grab the bytes from any location, without caring what the type the 
compiler considers it. Sometimes this is useful; more often it is a 
source of bugs.

In Python, *names* have no type, but *objects* (values) do. Because names 
are untyped, the one name (say, x) might be store a float one minute, 
then later have a list assigned to it, then a string, then a float again. 
But at any instant, whatever the value of x, it is an object, and objects 
always have a type no matter what name they are bound to. The type 
information is *part of the object*, rather than part of the name.

Because Python considers all objects to be typed, there is no concept of 
extracting the raw bytes from a list. (Of course lists actually are made 
out of bytes, but you cannot access them from pure Python code.)


So, yes, Python has types, just as C has types, but the difference is 
that Python associates the type with the *value* (object) rather than a 
storage location (variable).


But no, we can't give a complete list of all types, because there is no 
limit to the number of types. There are a certain number of built-in 
types, plus many more types which are available from the standard 
library, plus an infinite number of custom types you can create yourself.

You can get a list of the common built-in types and the standard library 
types from the Fine Manual:

http://docs.python.org/2/library/

See also:

http://docs.python.org/2/reference/datamodel.html


There are also built-in types which are essentially undocumented, and 
used as implementation details of higher-level objects like functions, 
methods, and so forth. You are not expected to use these directly. 
Instead, you just use the function itself.


If you are unfamiliar with Object Oriented Programming, you can broadly 
speaking consider types to be like smart structs that carry code around 
with them. There is no limit to the number of possible structs, and 
likewise there is no limit to the number of possible types.


 The documentation (http://docs.python.org/2/library/stdtypes.html)
 states The principal built-in types are numerics, sequences, mappings,
 files, classes, instances and exceptions.

Yes, they are the principal types, but there are many others.

There are three different built-in numeric types:

int
long
float

plus Decimal and Fraction in the standard library;

There are two standard built-in sequence types:

list
tuple

plus others in the standard library, such as namedtuple;

There is one standard built-in mapping type:

dict

plus at least two more in the standard library, defaultdict and 
ordereddict;

etc. You can read the docs more easily than I can copy the types out.



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


License status of pycollada?

2013-01-07 Thread Gene Heskett
Greetings all;

Trying to collect all the dependencies of FreeCad-0.13, but it appears that 
pycollada is behind some sort of a login/paywall on github.  Is anyone here 
familiar with how that works?

Thanks.

Cheers, Gene
-- 
There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order.
-Ed Howdershelt (Author)
My web page: http://coyoteden.dyndns-free.com:85/gene is up!
My views 
http://www.armchairpatriot.com/What%20Has%20America%20Become.shtml
Mr. Cole's Axiom:
The sum of the intelligence on the planet is a constant; the
population is growing.
I was taught to respect my elders, but its getting 
harder and harder to find any...
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Numpy outlier removal

2013-01-07 Thread Joseph L. Casale
 In other words: this approach for detecting outliers is nothing more than 

 a very rough, and very bad, heuristic, and should be avoided.

Heh, very true but the results will only be used for conversational purposes.
I am making an assumption that the data is normally distributed and I do expect
valid results to all be very nearly the same.

 You can read up more about outlier detection, and the difficulties 
 thereof, here:


I much appreciate the links and the thought in the post. I'll admit I didn't
realize outlier detection was as involved.


Again, thanks!
jlc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regular expression : the dollar sign ($) work with re.match() or re.search() ?

2013-01-07 Thread Steven D'Aprano
On Mon, 07 Jan 2013 01:45:58 -0800, iMath wrote:

 在 2012年9月26日星期三UTC+8下午3时38分50秒,iMath写道:
 I only know  the dollar sign ($) will match a pattern from the
 
 end of a string,but which method does it work with ,re.match() or
 re.search()  ?
 
 I thought re.match('h.$', 'hbxihi') will match ‘hi’ ,but it does not .so
 why ?


re.match only matches at the *start* of the string, so h.$ tries to 
match:

* start of string
* literal h
* any character
* end of string


You want re.search, which will search the entire string and match hi at 
the end of the string.


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


Re: running multiple django/bottle instances

2013-01-07 Thread andrea crotti
Not really, on the staging server we are using the django/bottle webserver..

Anyway I was thinking that a great possible solution might be to set
up something like buildbot to:
- checkout all the needed branches

- run the various servers for all of them on different ports, where maybe the
  mapping  port-branch is set from somewhere

- run all the unit tests for them and make the results available

With a similar configuration we would probably be very happy already,
anyone doing something similar?

2013/1/7 Michel Kunkler michel.kunk...@gmail.com:
 As you are certainly running a production server like Apache, your problem
 is actually not Python related.
 If you want to run your applications on different ports, take a look on e.g.
 Apaches virtual host configurations.
 http://httpd.apache.org/docs/2.2/vhosts/examples.html

 Am 03.01.2013 17:35, schrieb Andrea Crotti:

 I'm working on a quite complex web app that uses django and bottle
 (bottle for the API which is also restful).

 Before I came they started to use a staging server to be able to try out
 things properly before they get published, but now we would like to have
 the possibility to see multiple branches at a time.

 First we thought about multiple servers, but actually since bottle and
 django can be made to run on different ports, I thought why not running
 everything on one server on different ports?

 We also use elasticsearch and couchdb for the data, but these two
 don't change that much and can just be a single instance.

 So what would be really great could be

 staging_server/branch_x
 staging_server/branch_y

 and something keeps track of all the various branches tracked, and run
 or keeps running bottle/django on different ports for the different
 branches.

 Is there something in the wonderful python world which I could bend to
 my needs?

 I'll probably have to script something myself anyway, but any
 suggestions is welcome, since I don't have much experience with web
 stuff..


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


Re: License status of pycollada?

2013-01-07 Thread Chris Rebert
On Sunday, January 6, 2013, Gene Heskett wrote:

 Greetings all;

 Trying to collect all the dependencies of FreeCad-0.13, but it appears that
 pycollada is behind some sort of a login/paywall on github.  Is anyone here
 familiar with how that works?


Er, what? The repo seems freely browseable.
Looks like it's under a standard 3-clause BSD-style license:
https://github.com/pycollada/pycollada/blob/master/COPYING


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


Re: Over 30 types of variables available in python ?

2013-01-07 Thread Duncan Booth
chaouche yacine yacinechaou...@yahoo.com wrote:

 
 booleans
 ints, floats, longs, complexes
 strings, unicode strings
 lists, tuples, dictionaries, dictionary views, sets, frozensets,
 buffers, bytearrays, slices functions, methods, code
 objects,modules,classes, instances, types, nulls (there is exactly one
 object of type Null which is None), tracebacks, frames generators,
 iterators, xranges, files,
 
 memoryviews,
 context managers,
 
 These are all listed in this page
 http://docs.python.org/2/library/stdtypes.html as built-in types. Am I
 getting anything wrong here ? I'm a bit confused about it. I have
 never seen so many types in the few programming languages I saw. 

Instances aren't types (though types themselves are instances): every 
object in Python is an instance.

If you want a list of types that exist in your particular copy of Python 
then you can print it out easily enough:


def allsubclasses(base):
mod = base.__module__
if mod in ('builtins', '__builtin__', 'exceptions'):
yield getattr(base, '__qualname__', base.__name__)
else:
yield {}.{}.format(base.__module__, getattr(base, 
'__qualname__', base.__name__))
for typ in type.__subclasses__(base):
for t in allsubclasses(typ): yield t

all_types = sorted(set(allsubclasses(object)), key=str.lower)
print(len(all_types))
print(all_types)


That won't show any types that haven't been imported, but it gives me  
293 types that are all loaded on startup in Python 3.3 and 150 in Python 
2.7.

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


what’s the difference between socket.send() and socket.sendall() ?

2013-01-07 Thread iMath
what’s the difference between socket.send() andsocket.sendall() ?


It is so hard
for me to tell the difference
between them from the python doc

so what is the difference between them ?

and each one is suitable for which case ?-- 
http://mail.python.org/mailman/listinfo/python-list


Gangnam Style in line for UK dictionary inclusion

2013-01-07 Thread Constantine
Gangnam Style in line for UK dictionary inclusion 
http://adf.ly/2836760/news.yahoo.com/gangnam-style-line-uk-dictionary-inclusion-134517741.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with Unicode char in Python 3.3.0

2013-01-07 Thread Franck Ditter
In article mailman.175.1357492817.2939.python-l...@python.org,
 marduk mar...@python.net wrote:

 On Sun, Jan 6, 2013, at 11:43 AM, Franck Ditter wrote:
  Hi !
  I work on MacOS-X Lion and IDLE/Python 3.3.0
  I can't get the treble key (U1D11E) !
  
   \U1D11E
  SyntaxError: (unicode error) 'unicodeescape' codec can't 
  decode bytes in position 0-6: end of string in escape sequence
  
 
 You probably meant:
 
  '\U0001d11e'
 
 
 For that synax you must use either '\u' or '\U' (i.e.
 specify either 4 or 8 hex digits).
 
 http://docs.python.org/2/howto/unicode#unicode-literals-in-python-source-code

 print('\U0001d11e')
Traceback (most recent call last):
  File pyshell#1, line 1, in module
print('\U0001d11e')
UnicodeEncodeError: 'UCS-2' codec can't encode character '\U0001d11e' 
in position 0: Non-BMP character not supported in Tk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with Unicode char in Python 3.3.0

2013-01-07 Thread Chris Angelico
On Mon, Jan 7, 2013 at 11:57 PM, Franck Ditter nob...@nowhere.org wrote:
  print('\U0001d11e')
 Traceback (most recent call last):
   File pyshell#1, line 1, in module
 print('\U0001d11e')
 UnicodeEncodeError: 'UCS-2' codec can't encode character '\U0001d11e'
 in position 0: Non-BMP character not supported in Tk

That's a different issue; IDLE can't handle non-BMP characters. Try it
from the terminal if you can - on my Linux systems (Debians and
Ubuntus with GNOME and gnome-terminal), the terminal is set to UTF-8
and quite happily accepts the full Unicode range. On Windows, that may
well not be the case, though.

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


Re: Problem with Unicode char in Python 3.3.0

2013-01-07 Thread Terry Reedy

On 1/7/2013 7:57 AM, Franck Ditter wrote:


 print('\U0001d11e')
Traceback (most recent call last):
   File pyshell#1, line 1, in module
 print('\U0001d11e')
UnicodeEncodeError: 'UCS-2' codec can't encode character '\U0001d11e'
in position 0: Non-BMP character not supported in Tk


The message comes from printing to a tk text widget (the IDLE shell), 
not from creating the 1 char string. c = '\U0001d11e' works fine. When 
you have problems with creating and printing unicode, *separate* 
creating from printing to see where the problem is. (I do not know if 
the brand new tcl/tk 8.6 is any better.)


The windows console also chokes, but with a different message.

 c='\U0001d11e'
 print(c)
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\Programs\Python33\lib\encodings\cp437.py, line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001d11e' 
in posit

ion 0: character maps to undefined

Yes, this is very annoying, especially in Win 7.

--
Terry Jan Reedy

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


Re: what’s the difference between socket.send() and socket.sendall() ?

2013-01-07 Thread Thomas Rachel

Am 07.01.2013 11:35 schrieb iMath:

what’s the difference between socket.send() and socket.sendall() ?

It is so hard for me to tell the difference between them from the python doc

so what is the difference between them ?

and each one is suitable for which case ?



The docs are your friend. See

http://docs.python.org/2/library/socket.html#socket.socket.sendall

| [...] Unlike send(), this method continues to send data from string
| until either all data has been sent or an error occurs.

HTH,

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


Re: Gangnam Style in line for UK dictionary inclusion

2013-01-07 Thread GadgetSteve
On Monday, January 7, 2013 12:50:00 PM UTC, Constantine wrote:
 Gangnam Style in line for UK dictionary inclusion 
 http://adf.ly/2836760/news.yahoo.com/gangnam-style-line-uk-dictionary-inclusion-134517741.html

And this has to do with python how?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Gangnam Style in line for UK dictionary inclusion

2013-01-07 Thread Dave Angel
On 01/07/2013 08:22 AM, GadgetSteve wrote:
 On Monday, January 7, 2013 12:50:00 PM UTC, Constantine wrote:
 Trying to get control:   
 http://AboutToTrashYou.invalid/2892929384736760/news.yahoo.com/Whatever-you-like-it-wont44work134517741.html
 And this has to do with python how?

When replying to obvious spam, please don't quote the original link
(unless you thoroughly mangle it).  That just doubles the exposure so
more people are likely to click there.

adfly is a well-known adware virus/trojan/annoyance.  People on Windows
machines may have to remove the crud it installs.





-- 

DaveA

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


Re: Over 30 types of variables available in python ?

2013-01-07 Thread marduk
So I guess if one *really* wanted to compare C variables to Python
variables, you could say that all python variables are of type void*
except Python does all mallocs/frees and the casting for you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Over 30 types of variables available in python ?

2013-01-07 Thread Dave Angel
On 01/07/2013 09:32 AM, marduk wrote:
 So I guess if one *really* wanted to compare C variables to Python
 variables, you could say that all python variables are of type void*
 except Python does all mallocs/frees and the casting for you.

A better analogy would be to C++, and all names would be something like 
shared_ptrobject*.  And (except for old-style classes) all actual data
is of a type derived from object.





-- 

DaveA

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


Re: Over 30 types of variables available in python ?

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 1:45 AM, Dave Angel d...@davea.name wrote:
 On 01/07/2013 09:32 AM, marduk wrote:
 So I guess if one *really* wanted to compare C variables to Python
 variables, you could say that all python variables are of type void*
 except Python does all mallocs/frees and the casting for you.

 A better analogy would be to C++, and all names would be something like
 shared_ptrobject*.  And (except for old-style classes) all actual data
 is of a type derived from object.

But yes, a C pointer variable is closest to a Python local, with
actual content always stored on the heap.

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


Re: Numpy outlier removal

2013-01-07 Thread Oscar Benjamin
On 7 January 2013 05:11, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Mon, 07 Jan 2013 02:29:27 +, Oscar Benjamin wrote:

 On 7 January 2013 01:46, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 On Sun, 06 Jan 2013 19:44:08 +, Joseph L. Casale wrote:

 I'm not sure that this approach is statistically robust. No, let me be
 even more assertive: I'm sure that this approach is NOT statistically
 robust, and may be scientifically dubious.

 Whether or not this is statistically robust requires more explanation
 about the OP's intention.

 Not really. Statistics robustness is objectively defined, and the user's
 intention doesn't come into it. The mean is not a robust measure of
 central tendency, the median is, regardless of why you pick one or the
 other.

Okay, I see what you mean. I wasn't thinking of robustness as a
technical term but now I see that you are correct.

Perhaps what I should have said is that whether or not this matters
depends on the problem at hand (hopefully this isn't an important
medical trial) and the particular type of data that you have; assuming
normality is fine in many cases even if the data is not really
normal.


 There are sometimes good reasons for choosing non-robust statistics or
 techniques over robust ones, but some techniques are so dodgy that there
 is *never* a good reason for doing so. E.g. finding the line of best fit
 by eye, or taking more and more samples until you get a statistically
 significant result. Such techniques are not just non-robust in the
 statistical sense, but non-robust in the general sense, if not outright
 deceitful.

There are sometimes good reasons to get a line of best fit by eye. In
particular if your data contains clusters that are hard to separate,
sometimes it's useful to just pick out roughly where you think a line
through a subset of the data is.


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


Re: what’s the difference between socket.send() and socket.sendall() ?

2013-01-07 Thread Steven D'Aprano
On Mon, 07 Jan 2013 18:35:20 +0800, iMath wrote:

 p class=MsoNormalttspan lang=EN-US style=font-size: 12pt;
 color: white; background-color: rgb(68, 110, 248); background-position:
 initial initial; background-repeat: initial initial; what’s the
 difference between socket/span/span lang=EN-US
 style=font-size: 12pt; .send() andnbsp;span style=color: white;
 background-color: rgb(68, 110, 248); background-position: initial
 initial; background-repeat: initial initial; socket/span.sendall()
 ?/span/tt /p


Please re-send your question as text, instead of as HTML (so-called rich 
text). Since many people are reading this forum via Usenet, sending HTML 
is considered abusive. This is a text newsgroup, not a binary newsgroup.

If you *must* use a client that sends HTML, please make sure that it 
ALWAYS sends a plain text version of your message as well. But here are 
eight reasons you should not rely on fancy formatting (colours, fonts, 
bold, etc.) in text-based media such as email (or news):

- HTML code in email is one of the top 3 signs of spam. Many people
  send rich text email straight to the trash as a way of eliminating
  spam.

- HTML code in email is a privacy and security risk. For example,
  that means that the sender can track whether or not you have read
  the email using web bugs whether or not you consent to being
  tracked. There are viruses, spyware and other malware that can be
  transmitted through HTML code in email. For this reason, many
  people filter HTML email straight to the trash.

- HTML code forces your choice in font, font size, colours, etc. on
  the reader. Some people prefer to read emails using their own
  choice of font rather than yours, and consider it rude for others
  to try to force a different font. Sending white text on coloured 
  background is especially nasty, because it hurts readability of
  even for people with perfect vision.

- Even if readers don't mind the use of rich text in principle, in
  practice once they have received enough emails with pink text on a
  purple and yellow background with blinking stars and dancing fairies
  all over the page, in pure self-defence they may disable or delete 
  HTML emails.

- Use of colour for emphasis discriminates against the approximately
  10% of the male population who are colour-blind.

- Use of italics or other formatting may discriminate against those 
  who are blind and using screen readers to read their email. I 
  once was on a maths mailing list for about three years before I
  realised that the most prolific and helpful person there was as 
  blind as a bat.

- Programming is a *text-based* activity. Code depends on WHAT you
  write, not its colour, or the font you use, or whether there are
  smiley faces in the background winking at you. So especially in
  programming circles, many people find HTML code in emails to be a
  distraction and an annoyance. Being able to express yourself in 
  plain text without colours and fonts is a good practice for any
  programmer to get used to.

- Even if you think that people who dislike HTML emails are wrong, or
  silly, or being precious, or completely nuts, nevertheless you should
  indulge us. You are asking for free advice. It does not pay for you to
  offend or annoy those you are asking for help. 


(Apologies to anyone on the tutor mailing list who has already seen 
this message earlier today.)



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


Re: Numpy outlier removal

2013-01-07 Thread Robert Kern

On 07/01/2013 15:20, Oscar Benjamin wrote:

On 7 January 2013 05:11, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:

On Mon, 07 Jan 2013 02:29:27 +, Oscar Benjamin wrote:


On 7 January 2013 01:46, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:

On Sun, 06 Jan 2013 19:44:08 +, Joseph L. Casale wrote:

I'm not sure that this approach is statistically robust. No, let me be
even more assertive: I'm sure that this approach is NOT statistically
robust, and may be scientifically dubious.


Whether or not this is statistically robust requires more explanation
about the OP's intention.


Not really. Statistics robustness is objectively defined, and the user's
intention doesn't come into it. The mean is not a robust measure of
central tendency, the median is, regardless of why you pick one or the
other.


Okay, I see what you mean. I wasn't thinking of robustness as a
technical term but now I see that you are correct.

Perhaps what I should have said is that whether or not this matters
depends on the problem at hand (hopefully this isn't an important
medical trial) and the particular type of data that you have; assuming
normality is fine in many cases even if the data is not really
normal.


Having outliers literally means that assuming normality is not fine. If 
assuming normality were fine, then you wouldn't need to remove outliers.


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


When is overriding __getattr__ is useful?

2013-01-07 Thread Rodrick Brown
Can someone provide an example why one would want to override __getattr__
and __getattribute__ in a class?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: what’s the difference between socket.send() and socket.sendall() ?

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 2:28 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 I
   once was on a maths mailing list for about three years before I
   realised that the most prolific and helpful person there was as
   blind as a bat.

And that, I think, is what s/he would have most wanted: three years
(more, most likely) without any sort of special treatment. It's all
very well to talk about anti-discrimination laws, but on the internet,
nobody knows you're a bat, if I can mangle that expression without
offending people. We have some excellent people on a couple of MUDs
I'm on who are, similarly, blind and using screen-readers. Again, you
don't even know that that's the case until/unless a question comes out
about some piece of ASCII art (which there's a very VERY little of in
Threshold), or some client-specific question hints at the fact that
s/he is using one of the reader-friendly clients (which are fairly
ugly to the sighted).

As to the use of color for emphasis, though - I don't think the OP
used it like that. I've no idea what the significance of white-on-blue
words was, there; it completely eludes me. Maybe he was sending a
secret message in the color codes? In any case, Steven's eight reasons
are absolutely right; when HTML code isn't adding information, it
should be stripped, and when it is adding information, you risk a
large proportion of people not seeing it. So there's never a good time
to use HTML.

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


Vigil, the eternal morally vigilant programming language

2013-01-07 Thread Alain Ketterlin

I just came across Vigil, an extension to python for serious software
engineers, at https://github.com/munificent/vigil and thought everybody
in this group would be interested (sorry if it has been announced
before).

From README:

| Vigil is a very safe programming language, and an entry in the January
| 2013 PLT Games competition.
| 
| Many programming languages claim to take testing, contracts and safety
| seriously, but only Vigil is truly vigilant about not allowing code
| that fails to pass programmatic specifications.

Enjoy.

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


Re: Vigil, the eternal morally vigilant programming language

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 3:01 AM, Alain Ketterlin
al...@dpt-info.u-strasbg.fr wrote:

 I just came across Vigil, an extension to python for serious software
 engineers, at https://github.com/munificent/vigil and thought everybody
 in this group would be interested (sorry if it has been announced
 before).

It's the logical derivation of the principle that every program, once
written, could be shortened by at least one instruction and contains
at least one bug. From that, you can deduce that every program can be
logically reduced to a single instruction that doesn't work.

Vigil assists you with this logical reduction.

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


Re: problem with exam task for college

2013-01-07 Thread jeltedeproft
ok after another round of reparations, my update works again and it updates the 
fuel meter, but i still can't get the view of the spaceship to rotate, for now 
only the direction the spaceship accelerates when pressing up changes after a 
rotation, but the spaceship itself keeps pointing up. This is the code for the 
rotating :p.s : the problem has to be in this code because the update of 
the view of the position of the spaceship does work.


def update(self,dt):
self.velocity = self.velocity + (self.acceleration * dt)
self.pos = self.pos + self.velocity * dt
a = 0
b = 0
if scene.kb.keys:
a = a + 0.001 
s = scene.kb.getkey()
if (s == up):
if self.zicht.meter.height != 0:
self.velocity = self.velocity + self.gas
self.vlam.visible = True
b = b + 2
self.zicht.meter.height = self.zicht.meter.height - 0.1
self.zicht.update
if (s == left):
self.gas = rotate(self.gas,angle = math.pi/10, axis = (0,0,1))
(x,y,z) = self.frame.axis
self.frame.axis = (x,y,z-0.1)
if (s == right) :
self.gas = rotate(self.gas,angle = -(math.pi/10), axis = 
(0,0,1))
(x,y,z) = self.frame.axis
self.frame.axis = (x,y,z+0.1)
if (a == 0):
self.vlam.visible = False
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to modify this script?

2013-01-07 Thread Kurt Hansen

Den 06/01/13 16.12, chaouche yacine skrev:

I'm not confident this would run on gedit. It works on a python
interpreter if you have a file named data.txt in the same directory
containing your sample data.

It surely has to do with how gedit works then, because the $ sign
isn't used in python, this business should be a gedit convention. And
sorry, I can't help on that, I'm not a user of gedit myself. Fortunately
others have answered and I beleive one of the solutions worked for you.


It does not seem to be the case :-(

Thank you for trying to help.



*From:* Kurt Hansen kurt@ugyldig.invalid
*To:* python-list@python.org
*Sent:* Sunday, January 6, 2013 3:21 PM
*Subject:* Re: How to modify this script?

Den 06/01/13 15.01, chaouche yacine wrote:
  Well, I'm not answering your question since I am rewriting the script,
  because I prefer it this way :)
 
  def addline(line):
   return tr%s/tr\n % line
[cut]

I surpose I shall put your code between $ and ?

  printed
 
table
  trtd colspan='3'Price table/td/tr
  trtd1 /tdtd Green apple /tdtd $1/td/tr
  trtd5 /tdtd Green apples /tdtd $4/td/tr
  trtd10 /tdtd Green apples /tdtd $7/td/tr
  /table
   

Aha, so you tested it yourself?

When running this in Gedit on four lines of tab-separated text the
output is:

%s/tr\n % line

def addcolumn(item,nb_columns):
 if nb_columns != 3:
 return td colspan='%s'%s/td % (3 - nb_columns + 1, item)
 return td%s/td % item

output = table\n
for line in file(data.txt):
 items = line.strip().split(\t)
 columns = 
 for item in items :
 columns += addcolumn(item,len(items))
 output  += addline(columns)


output += /table
print output
 
-- Venlig hilsen
Kurt Hansen
-- http://mail.python.org/mailman/listinfo/python-list





--
Venlig hilsen
Kurt Hansen
--
http://mail.python.org/mailman/listinfo/python-list


Re: When is overriding __getattr__ is useful?

2013-01-07 Thread Albert Hopkins


On Mon, Jan 7, 2013, at 10:54 AM, Rodrick Brown wrote:
 Can someone provide an example why one would want to override __getattr__
 and __getattribute__ in a class?


They're good for cases when you want to provide an attribute-like
quality but you don't know the attribute in advance.

For example, the xmlrpclib uses __getattr__ to expose XML-RPC methods
over the wire when it doesn't necessarily know what methods are exposed
by the service.  This allows you do simply do

 service.method(*args)

And have the method seem like it's just a local method on an object.


There are countless other examples.  But that's just one that can be
found in the standard library.

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


Re: problem with exam task for college

2013-01-07 Thread Vincent Vande Vyvre
Le 07/01/13 17:22, jeltedepr...@hotmail.com a écrit :
 ok after another round of reparations, my update works again and it updates 
 the fuel meter, but i still can't get the view of the spaceship to rotate, 
 for now only the direction the spaceship accelerates when pressing up 
 changes after a rotation, but the spaceship itself keeps pointing up. This is 
 the code for the rotating :p.s : the problem has to be in this code 
 because the update of the view of the position of the spaceship does work.


 def update(self,dt):
 self.velocity = self.velocity + (self.acceleration * dt)
 self.pos = self.pos + self.velocity * dt
 a = 0
 b = 0
 if scene.kb.keys:
 a = a + 0.001 
 s = scene.kb.getkey()
 if (s == up):
 if self.zicht.meter.height != 0:
 self.velocity = self.velocity + self.gas
 self.vlam.visible = True
 b = b + 2
 self.zicht.meter.height = self.zicht.meter.height - 0.1
 self.zicht.update
 if (s == left):
 self.gas = rotate(self.gas,angle = math.pi/10, axis = (0,0,1))
 (x,y,z) = self.frame.axis
 self.frame.axis = (x,y,z-0.1)
 if (s == right) :
 self.gas = rotate(self.gas,angle = -(math.pi/10), axis = 
 (0,0,1))
 (x,y,z) = self.frame.axis
 self.frame.axis = (x,y,z+0.1)
 if (a == 0):
 self.vlam.visible = False
Are you sure with this code:

(x,y,z) = self.frame.axis ?

frame.axis is a 'cvisual.vector' and this unpacking cause a program
crashes with a segfault.

For left-rigth moves of the LEM, this code seems works:

--

if scene.kb.keys:
key = scene.kb.getkey()
if key == left:
# Set left deviation
self.frame.axis -= (0, 0, 0.05)
self.gas = vector(-sin(self.angle), cos(self.angle))

elif key == right:
# Set right deviation
self.frame.axis += (0, 0, 0.05)
self.gas = vector(sin(self.angle), cos(self.angle))

elif key == up:
self.deviate()

def deviate(self):
# Set modified velocity
self.frame.velocity += self.gas
self.frame.pos += self.frame.velocity
# Reset falling velocity
self.frame.velocity -= self.gas

--

with angle = PI / 2.0

-- 
Vincent V.V.
Oqapy https://launchpad.net/oqapy . Qarte
https://launchpad.net/qarte . PaQager https://launchpad.net/paqager
-- 
http://mail.python.org/mailman/listinfo/python-list


help

2013-01-07 Thread kwakukwatiah
download wxpython but whenever I try to use it I get this I’m a beginner in 
python pls I need help.
Traceback (most recent call last):
  File C:/Python27/wxp.py, line 1, in module
import wx
  File C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.py, line 
45, in module
from wx._core import *
  File C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py, line 4, 
in module
import _core_
ImportError: DLL load failed: %1 is not a valid Win32 application.-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to modify this script?

2013-01-07 Thread Gertjan Klein

Kurt Hansen wrote:


To convert tab-separated text lines into a HTML-table:


As you apparently didn't receive answers that worked for you I tried to 
get what you want to work and test it in Gedit. Here's the result:


$
lines = $GEDIT_SELECTED_TEXT.split(\n);
output = 'table\\n';

max_columns = 0
for line in lines:
col_count = len(line.split(\t))
if col_count \ max_columns:
max_columns = col_count

for line in lines:
if line == '':
continue

output += 'tr\';

columns = line.split(\t);
if len(columns) == 1:
output += ('td colspan=%s\' % max_columns) + line + 
'/td\/tr\\n'

continue

for item in columns:
output += 'td\' + item + '/td\'

output += '/tr\\n';

output += '/table\';
return output


(Watch out for line wraps! I don't know how to stop Thunderbird from 
inserting them.)


It really isn't all that difficult. The code determines the (maximum) 
number of columns present. It then processes each line; if one is found 
with exactly one column (i.e., no tabs), it applies a colspan equal to 
the maximum number of columns. This works for your test and similar data.


As I said, this is copy/pasted from a working Gedit snippet. If it works 
for you, I'd try experimenting a bit -- what should happen when the 
number of columns is larger than 1 but less than the maximum? 
Programming isn't magic. You might start enjoying it.


HTH,
Gertjan.


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


[Offtopic] Line fitting [was Re: Numpy outlier removal]

2013-01-07 Thread Steven D'Aprano
On Mon, 07 Jan 2013 15:20:57 +, Oscar Benjamin wrote:

 There are sometimes good reasons to get a line of best fit by eye. In
 particular if your data contains clusters that are hard to separate,
 sometimes it's useful to just pick out roughly where you think a line
 through a subset of the data is.

Cherry picking subsets of your data as well as line fitting by eye? Two 
wrongs do not make a right.

If you're going to just invent a line based on where you think it should 
be, what do you need the data for? Just declare this is the line I wish 
to believe in and save yourself the time and energy of collecting the 
data in the first place. Your conclusion will be no less valid.

How do you distinguish between data contains clusters that are hard to 
separate from data doesn't fit a line at all?

Even if the data actually is linear, on what basis could we distinguish 
between the line you fit by eye (say) y = 2.5x + 3.7, and the line I fit 
by eye (say) y = 3.1x + 4.1? The line you assert on the basis of purely 
subjective judgement can be equally denied on the basis of subjective 
judgement.

Anyone can fool themselves into placing a line through a subset of non-
linear data. Or, sadly more often, *deliberately* cherry picking fake 
clusters in order to fool others. Here is a real world example of what 
happens when people pick out the data clusters that they like based on 
visual inspection:

http://www.skepticalscience.com/images/TempEscalator.gif

And not linear by any means, but related to the cherry picking theme:

http://www.skepticalscience.com/pics/1_ArcticEscalator2012.gif


To put it another way, when we fit patterns to data by eye, we can easily 
fool ourselves into seeing patterns that aren't there, or missing the 
patterns which are there. At best line fitting by eye is prone to honest 
errors; at worst, it is open to the most deliberate abuse. We have eyes 
and brains that evolved to spot the ripe fruit in trees, not to spot 
linear trends in noisy data, and fitting by eye is not safe or 
appropriate.


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


test failed: test_urlwithfrag

2013-01-07 Thread Elli Lola
Dear python team,I never used python before and installed it today the first time, so I have no idea what to do about this failure: ./python -m test -v test_urlwithfrag== CPython 3.3.0 (default, Jan 4 2013, 23:08:00) [GCC 4.6.3]== Linux-3.2.0-35-generic-pae-i686-with-debian-wheezy-sid little-endian== /home/me/Programme/Python/Python-3.3.0/build/test_python_30744Testing
 with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, 
dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, 
verbose=0, bytes_warning=0, quiet=0, hash_randomization=1)[1/1] test_urlwithfragtest test_urlwithfrag crashed -- Traceback (most recent call last): File /home/me/Programme/Python/Python-3.3.0/Lib/test/regrtest.py, line 1213, in runtest_inner the_package = __import__(abstest, globals(), locals(), [])ImportError: No module named test.test_urlwithfrag1 test failed: test_urlwithfragIf you need more information, please tell me. It would be very great if you could help me. Thank you in advance.Elli Meisner
-- 
http://mail.python.org/mailman/listinfo/python-list


OT: local technical community portals

2013-01-07 Thread Jason Hsu
For the Minneapolis/St. Paul area of Minnesota, there is a technical community 
portal at http://tech.mn/.  You'll see that this portal has links to user 
groups, networking events, jobs, etc.  No, I didn't start this thread to tout 
this site.

MY QUESTION: What are the local technical community portals for other places, 
such as Chicago, Silicon Valley, Los Angeles, San Diego, Dallas, Atlanta, 
Boston, etc.?
-- 
http://mail.python.org/mailman/listinfo/python-list


I'm looking for a Junior level Django job (telecommute)

2013-01-07 Thread P Dev
I'm looking for a Junior level Django job (telecommute)

About me:

- less than year of experience with Python/Django

- Intermediate knowledge of Python/Django
- Experience with Linux
- Experience with Django ORM
- Passion for developing high-quality software and Python language

- I am able to use many aplications, for example (south, mptt, 
django-debug-toolbar etc.)

- English: communicative, still learning

I would like to develop my qualifications

I can be reached anytime via email at dreampr...@gmail.com

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


Re: help

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 10:35 AM,  kwakukwat...@gmail.com wrote:
 download wxpython but whenever I try to use it I get this I’m a beginner in
 python pls I need help.

 ImportError: DLL load failed: %1 is not a valid Win32 application.

Did you download the 64-bit version on a 32-bit system?

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


Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 4:58 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Anyone can fool themselves into placing a line through a subset of non-
 linear data. Or, sadly more often, *deliberately* cherry picking fake
 clusters in order to fool others. Here is a real world example of what
 happens when people pick out the data clusters that they like based on
 visual inspection:

 http://www.skepticalscience.com/images/TempEscalator.gif

And sensible people will notice that, even drawn like that, it's only
a ~0.6 deg increase across ~30 years. Hardly statistically
significant, given that weather patterns have been known to follow
cycles at least that long. But that's nothing to do with drawing lines
through points, and more to do with how much data you collect before
you announce a conclusion, and how easily a graph can prove any point
you like.

Statistical analysis is a huge science. So is lying. And I'm not sure
most people can pick one from the other.

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


INSTRUCTOR SOLUTIONS MANUAL :: Engineering Vibration 3rd Ed by Inman

2013-01-07 Thread kalvinmanual
I have solutions manuals to all problems and exercises in these textbooks. To 
get one in an electronic format contact me at: kalvinmanual(at)gmail(dot)com 
and let me know its title, author and edition. Please this service is NOT free.


INSTRUCTOR SOLUTIONS MANUAL :: Linear Algebra and Its Applications 3rd ed by 
David C. Lay
INSTRUCTOR SOLUTIONS MANUAL :: Linear Algebra Done Right, 2nd Ed by Sheldon 
Axler
INSTRUCTOR SOLUTIONS MANUAL :: Linear Algebra with Applications (6th Ed., S. 
Leon)
INSTRUCTOR SOLUTIONS MANUAL :: Linear Algebra with Applications 3rd Ed by Otto 
Bretscher
INSTRUCTOR SOLUTIONS MANUAL :: Linear Algebra With Applications, 2nd Edition by 
W. Keith Nicholson
INSTRUCTOR SOLUTIONS MANUAL :: Linear Circuit Analysis Time Domain, Phasor and 
Laplace.., 2nd Ed, Lin
INSTRUCTOR SOLUTIONS MANUAL :: Linear Circuit Analysis, 2nd Ed by DeCarlo , 
Pen-Min Lin
INSTRUCTOR SOLUTIONS MANUAL :: Linear dynamic systems and signals by Zoran Gajic
INSTRUCTOR SOLUTIONS MANUAL :: Linear Systems And Signals, 1stE, B P Lathi
INSTRUCTOR SOLUTIONS MANUAL :: Machine Design : An Integrated Approach (3rd 
Ed., Norton)
INSTRUCTOR SOLUTIONS MANUAL :: Machines and Mechanisms - Applied Kinematic 
Analysis, 3E by David H. Myszka
INSTRUCTOR SOLUTIONS MANUAL :: Managerial Accounting 11th Ed by Garrison  
Noreen
INSTRUCTOR SOLUTIONS MANUAL :: Managerial Accounting 13th E by Garrison, 
Noreen, Brewer
INSTRUCTOR SOLUTIONS MANUAL :: Managing Business and Professional Communication 
2nd ed Carley H. Dodd
INSTRUCTOR SOLUTIONS MANUAL :: Managing Business Process Flows: Principles of 
Operations Management(2nd Ed., Anupind, Chopra, Deshmukh, et al)
INSTRUCTOR SOLUTIONS MANUAL :: Managing Engineering and Technology (4th, Morse 
 Babcock)
INSTRUCTOR SOLUTIONS MANUAL :: Manufacturing Processes for Engineering 
Materials (5th Ed. Kalpakjian  Smith)
INSTRUCTOR SOLUTIONS MANUAL :: Materials - engineering, science, properties, 
and design
INSTRUCTOR SOLUTIONS MANUAL :: Materials and Processes in Manufacturing (9th 
Ed., E. Paul DeGarmo, J. T. Black,Kohser)
INSTRUCTOR SOLUTIONS MANUAL :: Materials for Civil and Construction Engineers 
3rd ED by Mamlouk,  Zaniewski 
INSTRUCTOR SOLUTIONS MANUAL :: Materials Science and Engineering- An 
Introduction ( 7th Ed., William D. Callister, Jr.)
INSTRUCTOR SOLUTIONS MANUAL :: Materials Science and Engineering- An 
Introduction (6th Ed., William D. Callister, Jr.)
INSTRUCTOR SOLUTIONS MANUAL :: MATH 1010 - Applied Finite Mathematics by  D.W. 
Trim
INSTRUCTOR SOLUTIONS MANUAL :: Mathematical Analysis, Second Edition by Tom M. 
Apostol
INSTRUCTOR SOLUTIONS MANUAL :: Mathematical Methods for Physicists 5 Ed, Arfken
INSTRUCTOR SOLUTIONS MANUAL :: Mathematical Methods for Physics and 
Engineering, (3rd Ed., Riley,Hobson)
INSTRUCTOR SOLUTIONS MANUAL :: Mathematical Methods in the Physical Sciences; 3 
edition by Mary L. Boas
INSTRUCTOR SOLUTIONS MANUAL :: Mathematical Models in Biology An Introduction 
(Elizabeth S. Allman  John A. Rhodes)
INSTRUCTOR SOLUTIONS MANUAL :: Mathematical Proofs - A Transition to Advanced 
Mathematics 2nd Ed by Chartrand, Polimeni, Zhang
INSTRUCTOR SOLUTIONS MANUAL :: Mathematical Techniques 4th ED by D W Jordan  P 
Smith
INSTRUCTOR SOLUTIONS MANUAL :: Mathematics for Economists, by Carl P. Simon , 
Lawrence E. Blume
INSTRUCTOR SOLUTIONS MANUAL :: Mathematics for Management Science - A Bridging 
Course by Tulett
INSTRUCTOR SOLUTIONS MANUAL :: Mathematics for Physicists by Susan Lea
INSTRUCTOR SOLUTIONS MANUAL :: Matrix Analysis and Applied Linear Algebra by 
Meyer
INSTRUCTOR SOLUTIONS MANUAL :: Matter and Interactions, 3rd Ed by Chabay, 
Sherwood
INSTRUCTOR SOLUTIONS MANUAL :: McGraw-Hill Ryerson Calculus  Advanced Function 
by Dearling, Erdman, et all
INSTRUCTOR SOLUTIONS MANUAL :: Mechanical Engineering Design 8th Ed by Shigley 
 Budynas
INSTRUCTOR SOLUTIONS MANUAL :: Mechanical Engineering Design 9th Ed by Shigley 
 Budynas
INSTRUCTOR SOLUTIONS MANUAL :: Mechanical Engineering Design, 7th Ed. by 
Mischke, Shigley
INSTRUCTOR SOLUTIONS MANUAL :: Mechanical Measurements (6th Ed., Beckwith, 
Marangoni  Lienhard)
INSTRUCTOR SOLUTIONS MANUAL :: Mechanical Vibrations ( Vol.1) 4th Ed., Rao
INSTRUCTOR SOLUTIONS MANUAL :: Mechanical Vibrations (3rd Ed., Rao)
INSTRUCTOR SOLUTIONS MANUAL :: Mechanical Vibrations 4th Ed SI Units by  Rao
INSTRUCTOR SOLUTIONS MANUAL :: Mechanics of Aircraft Structures, 2nd Ed by Sun
INSTRUCTOR SOLUTIONS MANUAL :: Mechanics of Fluids (8th Ed., Massey) 
INSTRUCTOR SOLUTIONS MANUAL :: Mechanics of Fluids 3rd ED Vol 1 by Merle C. 
Potter
INSTRUCTOR SOLUTIONS MANUAL :: Mechanics of Materials  5 edition by James M. 
Gere
INSTRUCTOR SOLUTIONS MANUAL :: Mechanics of Materials (6th Ed., Riley, Sturges 
 Morris)
INSTRUCTOR SOLUTIONS MANUAL :: Mechanics of Materials 4 E by Russell C. Hibbeler
INSTRUCTOR SOLUTIONS MANUAL :: Mechanics of Materials 4th Ed by  Beer Johnston
INSTRUCTOR SOLUTIONS MANUAL :: Mechanics of Materials 8th E by Russell C. 
Hibbeler
INSTRUCTOR 

Searching through two logfiles in parallel?

2013-01-07 Thread Victor Hooi
Hi,

I'm trying to compare two logfiles in Python.

One logfile will have lines recording the message being sent:

05:00:06 Message sent - Value A: 5.6, Value B: 6.2, Value C: 9.9

the other logfile has line recording the message being received

05:00:09 Message received - Value A: 5.6, Value B: 6.2, Value C: 9.9

The goal is to compare the time stamp between the two - we can safely assume 
the timestamp on the message being received is later than the timestamp on 
transmission.

If it was a direct line-by-line, I could probably use itertools.izip(), right?

However, it's not a direct line-by-line comparison of the two files - the lines 
I'm looking for are interspersed among other loglines, and the time difference 
between sending/receiving is quite variable.

So the idea is to iterate through the sending logfile - then iterate through 
the receiving logfile from that timestamp forwards, looking for the matching 
pair. Obviously I want to minimise the amount of back-forth through the file.

Also, there is a chance that certain messages could get lost - so I assume 
there's a threshold after which I want to give up searching for the matching 
received message, and then just try to resync to the next sent message.

Is there a Pythonic way, or some kind of idiom that I can use to approach this 
problem?

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


Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]

2013-01-07 Thread Oscar Benjamin
On 7 January 2013 17:58, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Mon, 07 Jan 2013 15:20:57 +, Oscar Benjamin wrote:

 There are sometimes good reasons to get a line of best fit by eye. In
 particular if your data contains clusters that are hard to separate,
 sometimes it's useful to just pick out roughly where you think a line
 through a subset of the data is.

 Cherry picking subsets of your data as well as line fitting by eye? Two
 wrongs do not make a right.

It depends on what you're doing, though. I wouldn't use an eyeball fit
to get numbers that were an important part of the conclusion of some
or other study. I would very often use it while I'm just in the
process of trying to understand something.

 If you're going to just invent a line based on where you think it should
 be, what do you need the data for? Just declare this is the line I wish
 to believe in and save yourself the time and energy of collecting the
 data in the first place. Your conclusion will be no less valid.

An example: Earlier today I was looking at some experimental data. A
simple model of the process underlying the experiment suggests that
two variables x and y will vary in direct proportion to one another
and the data broadly reflects this. However, at this stage there is
some non-normal variability in the data, caused by experimental
difficulties. A subset of the data appears to closely follow a well
defined linear pattern but there are outliers and the pattern breaks
down in an asymmetric way at larger x and y values. At some later time
either the sources of experimental variation will be reduced, or they
will be better understood but for now it is still useful to estimate
the constant of proportionality in order to check whether it seems
consistent with the observed values of z. With this particular dataset
I would have wasted a lot of time if I had tried to find a
computational method to match the line that to me was very visible so
I chose the line visually.


 How do you distinguish between data contains clusters that are hard to
 separate from data doesn't fit a line at all?


In the example I gave it isn't possible to make that distinction with
the currently available data. That doesn't make it meaningless to try
and estimate the parameters of the relationship between the variables
using the preliminary data.

 Even if the data actually is linear, on what basis could we distinguish
 between the line you fit by eye (say) y = 2.5x + 3.7, and the line I fit
 by eye (say) y = 3.1x + 4.1? The line you assert on the basis of purely
 subjective judgement can be equally denied on the basis of subjective
 judgement.

It gets a bit easier if the line is constrained to go through the
origin. You seem to be thinking that the important thing is proving
that the line is real, rather than identifying where it is. Both
things are important but not necessarily in the same problem. In my
example, the real line may not be straight and may not go through
the origin, but it is definitely there and if there were no
experimental problems then the data would all be very close to it.

 Anyone can fool themselves into placing a line through a subset of non-
 linear data. Or, sadly more often, *deliberately* cherry picking fake
 clusters in order to fool others. Here is a real world example of what
 happens when people pick out the data clusters that they like based on
 visual inspection:

 http://www.skepticalscience.com/images/TempEscalator.gif

 And not linear by any means, but related to the cherry picking theme:

 http://www.skepticalscience.com/pics/1_ArcticEscalator2012.gif


 To put it another way, when we fit patterns to data by eye, we can easily
 fool ourselves into seeing patterns that aren't there, or missing the
 patterns which are there. At best line fitting by eye is prone to honest
 errors; at worst, it is open to the most deliberate abuse. We have eyes
 and brains that evolved to spot the ripe fruit in trees, not to spot
 linear trends in noisy data, and fitting by eye is not safe or
 appropriate.

This is all true. But the human brain is also in many ways much better
than a typical computer program at recognising patterns in data when
the data can be depicted visually. I would very rarely attempt to
analyse data without representing it in some visual form. I also think
it would be highly foolish to go so far with refusing to eyeball data
that you would accept the output of some regression algorithm even
when it clearly looks wrong.


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


Re: Searching through two logfiles in parallel?

2013-01-07 Thread Oscar Benjamin
On 7 January 2013 22:10, Victor Hooi victorh...@gmail.com wrote:
 Hi,

 I'm trying to compare two logfiles in Python.

 One logfile will have lines recording the message being sent:

 05:00:06 Message sent - Value A: 5.6, Value B: 6.2, Value C: 9.9

 the other logfile has line recording the message being received

 05:00:09 Message received - Value A: 5.6, Value B: 6.2, Value C: 9.9

 The goal is to compare the time stamp between the two - we can safely assume 
 the timestamp on the message being received is later than the timestamp on 
 transmission.

 If it was a direct line-by-line, I could probably use itertools.izip(), right?

 However, it's not a direct line-by-line comparison of the two files - the 
 lines I'm looking for are interspersed among other loglines, and the time 
 difference between sending/receiving is quite variable.

 So the idea is to iterate through the sending logfile - then iterate through 
 the receiving logfile from that timestamp forwards, looking for the matching 
 pair. Obviously I want to minimise the amount of back-forth through the file.

 Also, there is a chance that certain messages could get lost - so I assume 
 there's a threshold after which I want to give up searching for the matching 
 received message, and then just try to resync to the next sent message.

 Is there a Pythonic way, or some kind of idiom that I can use to approach 
 this problem?

Assuming that you can impose a maximum time between the send and
recieve timestamps, something like the following might work
(untested):

def find_matching(logfile1, logfile2, maxdelta):
buf = {}
logfile2 = iter(logfile2)
for msg1 in logfile1:
if msg1.key in buf:
yield msg1, buf.pop(msg1.key)
continue
maxtime = msg1.time + maxdelta
for msg2 in logfile2:
if msg2.key == msg1.key:
yield msg1, msg2
break
buf[msg2.key] = msg2
if msg2.time  maxtime:
break
else:
yield msg1, 'No match'


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


Re: help

2013-01-07 Thread Ian Kelly
On Mon, Jan 7, 2013 at 12:37 PM, Chris Angelico ros...@gmail.com wrote:
 On Tue, Jan 8, 2013 at 10:35 AM,  kwakukwat...@gmail.com wrote:
 download wxpython but whenever I try to use it I get this I’m a beginner in
 python pls I need help.

 ImportError: DLL load failed: %1 is not a valid Win32 application.

 Did you download the 64-bit version on a 32-bit system?

Or perhaps a 32-bit wxPython version with a 64-bit Python installation?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: test failed: test_urlwithfrag

2013-01-07 Thread Irmen de Jong
On 7-1-2013 19:26, Elli Lola wrote:
 I never used python before and installed it today the first time, so I have 
 no idea what
 to do about this failure:
 
 
 $ ./python -m test -v test_urlwithfrag

[..snip..]

 ImportError: No module named 'test.test_urlwithfrag'
 
 1 test failed:
 test_urlwithfrag

The error message says it all, really: there is no regression test module called
test_urlwithfrag.  (At least, not on my python 3.3 installation)

Check the contents of your python-install-dir/Lib/test directory to see what 
is
available instead.


Irmen

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


Re: Searching through two logfiles in parallel?

2013-01-07 Thread Victor Hooi
Hi Oscar,

Thanks for the quick reply =).

I'm trying to understand your code properly, and it seems like for each line in 
logfile1, we loop through all of logfile2?

The idea was that it would remember it's position in logfile2 as well - since 
we can assume that the loglines are in chronological order - we only need to 
search forwards in logfile2 each time, not from the beginning each time.

So for example - logfile1:

05:00:06 Message sent - Value A: 5.6, Value B: 6.2, Value C: 9.9 
05:00:08 Message sent - Value A: 3.3, Value B: 4.3, Value C: 2.3
05:00:14 Message sent - Value A: 1.0, Value B: 0.4, Value C: 5.4

logfile2:

05:00:09 Message received - Value A: 5.6, Value B: 6.2, Value C: 9.9 
05:00:12 Message received - Value A: 3.3, Value B: 4.3, Value C: 2.3
05:00:15 Message received - Value A: 1.0, Value B: 0.4, Value C: 5.4

The idea is that I'd iterate through logfile 1 - I'd get the 05:00:06 logline - 
I'd search through logfile2 and find the 05:00:09 logline.

Then, back in logline1 I'd find the next logline at 05:00:08. Then in logfile2, 
instead of searching back from the beginning, I'd start from the next line, 
which happens to be 5:00:12.

In reality, I'd need to handle missing messages in logfile2, but that's the 
general idea.

Does that make sense? (There's also a chance I've misunderstood your buf code, 
and it does do this - in that case, I apologies - is there any chance you could 
explain it please?)

Cheers,
Victor

On Tuesday, 8 January 2013 09:58:36 UTC+11, Oscar Benjamin  wrote:
 On 7 January 2013 22:10, Victor Hooi victorh...@gmail.com wrote:
 
  Hi,
 
 
 
  I'm trying to compare two logfiles in Python.
 
 
 
  One logfile will have lines recording the message being sent:
 
 
 
  05:00:06 Message sent - Value A: 5.6, Value B: 6.2, Value C: 9.9
 
 
 
  the other logfile has line recording the message being received
 
 
 
  05:00:09 Message received - Value A: 5.6, Value B: 6.2, Value C: 9.9
 
 
 
  The goal is to compare the time stamp between the two - we can safely 
  assume the timestamp on the message being received is later than the 
  timestamp on transmission.
 
 
 
  If it was a direct line-by-line, I could probably use itertools.izip(), 
  right?
 
 
 
  However, it's not a direct line-by-line comparison of the two files - the 
  lines I'm looking for are interspersed among other loglines, and the time 
  difference between sending/receiving is quite variable.
 
 
 
  So the idea is to iterate through the sending logfile - then iterate 
  through the receiving logfile from that timestamp forwards, looking for the 
  matching pair. Obviously I want to minimise the amount of back-forth 
  through the file.
 
 
 
  Also, there is a chance that certain messages could get lost - so I assume 
  there's a threshold after which I want to give up searching for the 
  matching received message, and then just try to resync to the next sent 
  message.
 
 
 
  Is there a Pythonic way, or some kind of idiom that I can use to approach 
  this problem?
 
 
 
 Assuming that you can impose a maximum time between the send and
 
 recieve timestamps, something like the following might work
 
 (untested):
 
 
 
 def find_matching(logfile1, logfile2, maxdelta):
 
 buf = {}
 
 logfile2 = iter(logfile2)
 
 for msg1 in logfile1:
 
 if msg1.key in buf:
 
 yield msg1, buf.pop(msg1.key)
 
 continue
 
 maxtime = msg1.time + maxdelta
 
 for msg2 in logfile2:
 
 if msg2.key == msg1.key:
 
 yield msg1, msg2
 
 break
 
 buf[msg2.key] = msg2
 
 if msg2.time  maxtime:
 
 break
 
 else:
 
 yield msg1, 'No match'
 
 
 
 
 
 Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Searching through two logfiles in parallel?

2013-01-07 Thread Oscar Benjamin
On 7 January 2013 23:41, Victor Hooi victorh...@gmail.com wrote:
 Hi Oscar,

 Thanks for the quick reply =).

 I'm trying to understand your code properly, and it seems like for each line 
 in logfile1, we loop through all of logfile2?

No we don't. It iterates once through both files but keeps a buffer of
lines that are within maxdelta time of the current message.

The important line is the line that calls iter(logfile2). Since
logfile2 is replaced by an iterator when we break out of the inner for
loop and then re-enter our place in the iterator is saved. If you can
follow the interactive session below it should make sense:

 a = [1,2,3,4,5]
 for x in a:
...print x,
...
1 2 3 4 5
 for x in a:
...print x,
...
1 2 3 4 5
 it = iter(a)
 next(it)
1
 for x in it:
... print x,
...
2 3 4 5
 next(it)
Traceback (most recent call last):
  File stdin, line 1, in module
StopIteration
 for x in it:
... print x,
...
 it = iter(a)
 for x in it:
... print x,
... if x == 2: break
...
1 2
 for x in it:
... print x,
...
3 4 5


I'll repeat the code (with a slight fix):


def find_matching(logfile1, logfile2, maxdelta):
buf = {}
logfile2 = iter(logfile2)
for msg1 in logfile1:
if msg1.key in buf:
yield msg1, buf.pop(msg1.key)
continue
maxtime = msg1.time + maxdelta
for msg2 in logfile2:
if msg2.key == msg1.key:
yield msg1, msg2
break
buf[msg2.key] = msg2
if msg2.time  maxtime:
   yield msg1, 'No match'
   break
else:
yield msg1, 'No match'


Oscar



 The idea was that it would remember it's position in logfile2 as well - since 
 we can assume that the loglines are in chronological order - we only need to 
 search forwards in logfile2 each time, not from the beginning each time.

 So for example - logfile1:

 05:00:06 Message sent - Value A: 5.6, Value B: 6.2, Value C: 9.9
 05:00:08 Message sent - Value A: 3.3, Value B: 4.3, Value C: 2.3
 05:00:14 Message sent - Value A: 1.0, Value B: 0.4, Value C: 5.4

 logfile2:

 05:00:09 Message received - Value A: 5.6, Value B: 6.2, Value C: 9.9
 05:00:12 Message received - Value A: 3.3, Value B: 4.3, Value C: 2.3
 05:00:15 Message received - Value A: 1.0, Value B: 0.4, Value C: 5.4

 The idea is that I'd iterate through logfile 1 - I'd get the 05:00:06 logline 
 - I'd search through logfile2 and find the 05:00:09 logline.

 Then, back in logline1 I'd find the next logline at 05:00:08. Then in 
 logfile2, instead of searching back from the beginning, I'd start from the 
 next line, which happens to be 5:00:12.

 In reality, I'd need to handle missing messages in logfile2, but that's the 
 general idea.

 Does that make sense? (There's also a chance I've misunderstood your buf 
 code, and it does do this - in that case, I apologies - is there any chance 
 you could explain it please?)

 Cheers,
 Victor

 On Tuesday, 8 January 2013 09:58:36 UTC+11, Oscar Benjamin  wrote:
 On 7 January 2013 22:10, Victor Hooi victorh...@gmail.com wrote:

  Hi,

 

  I'm trying to compare two logfiles in Python.

 

  One logfile will have lines recording the message being sent:

 

  05:00:06 Message sent - Value A: 5.6, Value B: 6.2, Value C: 9.9

 

  the other logfile has line recording the message being received

 

  05:00:09 Message received - Value A: 5.6, Value B: 6.2, Value C: 9.9

 

  The goal is to compare the time stamp between the two - we can safely 
  assume the timestamp on the message being received is later than the 
  timestamp on transmission.

 

  If it was a direct line-by-line, I could probably use itertools.izip(), 
  right?

 

  However, it's not a direct line-by-line comparison of the two files - the 
  lines I'm looking for are interspersed among other loglines, and the time 
  difference between sending/receiving is quite variable.

 

  So the idea is to iterate through the sending logfile - then iterate 
  through the receiving logfile from that timestamp forwards, looking for 
  the matching pair. Obviously I want to minimise the amount of back-forth 
  through the file.

 

  Also, there is a chance that certain messages could get lost - so I assume 
  there's a threshold after which I want to give up searching for the 
  matching received message, and then just try to resync to the next sent 
  message.

 

  Is there a Pythonic way, or some kind of idiom that I can use to approach 
  this problem?



 Assuming that you can impose a maximum time between the send and

 recieve timestamps, something like the following might work

 (untested):



 def find_matching(logfile1, logfile2, maxdelta):

 buf = {}

 logfile2 = iter(logfile2)

 for msg1 in logfile1:

 if msg1.key in buf:

 yield msg1, buf.pop(msg1.key)

 continue

 maxtime = msg1.time + maxdelta

 for msg2 in logfile2:

   

Calculate Big Number

2013-01-07 Thread Nac Temha
Hello,
How to *quickly* calculate large numbers. For example
 (10**25) * (2**50)
11258999068426240L




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


How to implement mouse gesture by python or pyqt ?

2013-01-07 Thread iMath
It would be better to give me some examples .thanks in advance !

P.S. which module or lib are needed ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calculate Big Number

2013-01-07 Thread Oscar Benjamin
On 8 January 2013 00:44, Nac Temha nacctte...@gmail.com wrote:
 Hello,
 How to quickly calculate large numbers. For example
 (10**25) * (2**50)
 11258999068426240L

I just tested that line in the interpreter and it ran so quickly it
seemed instantaneous (maybe my computer is faster than yours).

Perhaps you could provide more of an explanation about what isn't fast
enough and why?


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


INSTRUCTOR SOLUTIONS MANUAL :: Classical Electrodynamics 2nd edition by John David Jackson

2013-01-07 Thread kalvinmanual
I have solutions manuals to all problems and exercises in these textbooks. To 
get one in an electronic format contact me at: kalvinmanual(at)gmail(dot)com 
and let me know its title, author and edition. Please this service is NOT free.

INSTRUCTOR SOLUTIONS MANUAL :: Calculus  8th Edition by Varberg, Purcell, Rigdon
INSTRUCTOR SOLUTIONS MANUAL :: Calculus - Early Transcendentals, 6th E, by 
Anton, Bivens, Davis
INSTRUCTOR SOLUTIONS MANUAL :: Calculus - Early Transcendentals, 7E, by Anton, 
Bivens, Davis
INSTRUCTOR SOLUTIONS MANUAL :: Calculus - Late Transcendentals Single Variable, 
8th Ed by Anton, Bivens, Davis
INSTRUCTOR SOLUTIONS MANUAL :: Calculus ( 9th Ed., Dale Varberg, Edwin Purcell 
 Steve Rigdon)
INSTRUCTOR SOLUTIONS MANUAL :: Calculus 2nd edition-M. Spivak
INSTRUCTOR SOLUTIONS MANUAL :: Calculus 3rd Ed by Michael Spivak
INSTRUCTOR SOLUTIONS MANUAL :: Calculus 6th ed by James Stewart
INSTRUCTOR SOLUTIONS MANUAL :: Calculus 8th Ed by Ron Larson, Robert P. 
Hostetler, Bruce H. Edwards
INSTRUCTOR SOLUTIONS MANUAL :: Calculus A Complete Course 6th Edition by by 
R.A. Adams
INSTRUCTOR SOLUTIONS MANUAL :: CALCULUS An Intuitive and Physical Approach 2nd 
ed by Morris Kline
INSTRUCTOR SOLUTIONS MANUAL :: Calculus and its Applications (11th Ed., Larry J 
Goldstein, Schneider, Lay   Asmar)
INSTRUCTOR SOLUTIONS MANUAL :: Calculus by Gilbert Strang
INSTRUCTOR SOLUTIONS MANUAL :: Calculus early transcendentals  8th Ed, by Anton 
Bivens Davis
INSTRUCTOR SOLUTIONS MANUAL :: Calculus Early Transcendentals, 5th Edition, 
JAMES STEWART
INSTRUCTOR SOLUTIONS MANUAL :: Calculus George Thomas 10th ed  Vol 1
INSTRUCTOR SOLUTIONS MANUAL :: Calculus of Variations MA 4311 LECTURE NOTES ( 
Russak )
INSTRUCTOR SOLUTIONS MANUAL :: Calculus On Manifolds by Spivak
INSTRUCTOR SOLUTIONS MANUAL :: Calculus One  Several Variables 8e by S Salas
INSTRUCTOR SOLUTIONS MANUAL :: Calculus Vol 2 by Apostol
INSTRUCTOR SOLUTIONS MANUAL :: Calculus Volume 1 by J. Marsden, A. Weinstein
INSTRUCTOR SOLUTIONS MANUAL :: Calculus With Analytic Geometry 4th ( Henry 
Edwards  David E. Penney)
INSTRUCTOR SOLUTIONS MANUAL :: Calculus with Applications 8 Edition by Lial, 
Greenwell,  Ritchey
INSTRUCTOR SOLUTIONS MANUAL :: Calculus, 4th edition stewart
INSTRUCTOR SOLUTIONS MANUAL :: Calculus, An Applied Approach, 7E, by Larson
INSTRUCTOR SOLUTIONS MANUAL :: Calculus, Early Transcendentals 7 Ed by Edwards 
 Penney
INSTRUCTOR SOLUTIONS MANUAL :: Calculus, Single and Multivariable, 4E.,Vol 1 
Vol 2 by Hughes-Hallett,McCallum
INSTRUCTOR SOLUTIONS MANUAL :: Calculus, Single Variable, 3E by 
Hughes-Hallett,McCallum
INSTRUCTOR SOLUTIONS MANUAL :: Chemical and Engineering Thermodynamics 3Ed by 
Stanley I. Sandler
INSTRUCTOR SOLUTIONS MANUAL :: Chemical Engineering Design (Coulson  
Richardson's Chemical Engineering - Volume 6) - (4th Ed., Sinnott)
INSTRUCTOR SOLUTIONS MANUAL :: Chemical Engineering Volume 1, 6th Edition, by 
Richardson, Coulson,Backhurst, Harker
INSTRUCTOR SOLUTIONS MANUAL :: Chemical, Biochemical, and Engineering 
Thermodynamics, 4th Ed by Sandler
INSTRUCTOR SOLUTIONS MANUAL :: Chemistry 2nd Edition Vol.1 by Julia Burdge
INSTRUCTOR SOLUTIONS MANUAL :: Chemistry, 10th Ed by Chang
INSTRUCTOR SOLUTIONS MANUAL :: Chip Design for Submicron VLSI CMOS Layout and 
Simulation, John P. Uyemura
INSTRUCTOR SOLUTIONS MANUAL :: Cisco Technical Solution Series IP Telephony 
Solution Guide Version 2.0
INSTRUCTOR SOLUTIONS MANUAL :: Classical Dynamics of Particles and Systems, 5th 
Ed, by Marion, Thornton
INSTRUCTOR SOLUTIONS MANUAL :: Classical Dynamics, A Contemporary Approach 
(Jorge V. Jose)
INSTRUCTOR SOLUTIONS MANUAL :: Classical Electrodynamics 2nd edition by John 
David Jackson
INSTRUCTOR SOLUTIONS MANUAL :: Classical Electrodynamics by John David Jackson
INSTRUCTOR SOLUTIONS MANUAL :: Classical Electrodynamics by Kasper Van Wijk
INSTRUCTOR SOLUTIONS MANUAL :: Classical Mechanics (Douglas Gregory)
INSTRUCTOR SOLUTIONS MANUAL :: Classical Mechanics 2nd Ed by Goldstein
INSTRUCTOR SOLUTIONS MANUAL :: CMOS Analog Circuit Design, 2ed by Phillip E. 
Allen, Douglas R. Holberg
INSTRUCTOR SOLUTIONS MANUAL :: CMOS- Circuit Design, Layout, and Simulation, 
Revised 2nd Ed by R. Jacob Baker
INSTRUCTOR SOLUTIONS MANUAL :: Cmos Digital Integrated Circuits , Sung-Mo 
Kang,Yusuf Leblebici
INSTRUCTOR SOLUTIONS MANUAL :: CMOS Mixed-Signal Circuit Design, 2nd Ed by  R. 
Jacob Baker
INSTRUCTOR SOLUTIONS MANUAL :: CMOS VLSI Design Circuit  Design Perspective 
3rd Ed by Haris  West
INSTRUCTOR SOLUTIONS MANUAL :: College Algebra 8th Ed by Michael Sullivan
INSTRUCTOR SOLUTIONS MANUAL :: COLLEGE ALGEBRA AND TRIGONOMETRY 6th E  by 
Aufmann, Barker, Verity
INSTRUCTOR SOLUTIONS MANUAL :: College Geometry A Discovery Approach 2nd E by 
David Kay
INSTRUCTOR SOLUTIONS MANUAL :: College Physics 8 ED by Serway, Faughn, Vuille
INSTRUCTOR SOLUTIONS MANUAL :: College Physics 9 ED by Serway, Faughn, Vuille
INSTRUCTOR SOLUTIONS MANUAL :: Communication Networks, 2e, Alberto Leon-Garcia, 

Re: Ubuntu Python -dbg packages

2013-01-07 Thread Lee Harr

 Ok, so now I tried python3.3-dbg but I don't think the pyqt
 modules are compiled for 3.3 and that may be preventing
 the import there.

 Those extension modules would need to be compiled for
 an exactly matching python interpreter, right?

 For Windows visual C compiler, that is true. I do not know about gcc on 
 *nix. I have gotten the impression that it is not necessarily so, except 
 as the C api has changed in a way that affects the extension library. 
 (Given that 3.3 is 3 months old, after 6 months of alpha/beta releases, 
 and has some major improvements, it is past time for libraries that need 
 recompiling to be so.)


Well... lets just say that with the ubuntu python3.3 package it doesn't work:


$ python3.3
Python 3.3.0 (default, Sep 29 2012, 17:17:45) 
[GCC 4.7.2] on linux
Type help, copyright, credits or license for more information.
 import PyQt4
 import PyQt4.QtCore
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: No module named 'PyQt4.QtCore'


[plus a whole other problem...]

Error in sys.excepthook:
Traceback (most recent call last):
  File /usr/lib/python3/dist-packages/apport_python_hook.py, line 64, in 
apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File /usr/lib/python3/dist-packages/apport/__init__.py, line 4, in module
    from apport.report import Report
  File /usr/lib/python3/dist-packages/apport/report.py, line 30, in module
    import apport.fileutils
  File /usr/lib/python3/dist-packages/apport/fileutils.py, line 23, in 
module
    from apport.packaging_impl import impl as packaging
  File /usr/lib/python3/dist-packages/apport/packaging_impl.py, line 20, in 
module
    import apt
  File /usr/lib/python3/dist-packages/apt/__init__.py, line 21, in module
    import apt_pkg
ImportError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: No module named 'PyQt4.QtCore'




 So, python3-dbg _should_ be able to import this?

 Given that python3 and python3-dbg import the same PyQt4 file, and that 
 you spell PyQt4.QtCore the same (I checked), I am as surprised as you. 

Ok. I will file a Ubuntu bug report.



  import test.test_imp as t; t.test_main()

This does not work for me:

$ python3
Python 3.2.3 (default, Oct 19 2012, 19:53:57) 
[GCC 4.7.2] on linux2
Type help, copyright, credits or license for more information.
 import test
 test.test_imp
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'module' object has no attribute 'test_imp'


$ python3.3
Python 3.3.0 (default, Sep 29 2012, 17:17:45) 
[GCC 4.7.2] on linux
Type help, copyright, credits or license for more information.
 import test
 test.test_imp
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'module' object has no attribute 'test_imp'

[plus that whole Error in sys.excepthook thing too...]


Should this be another bug report for the ubuntu packages?

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


Difference between these two lists?

2013-01-07 Thread andydtaylor
Hi,

Python newbie here again - this is probably a quick one. What's the difference 
between the lines I've numbered 1. and 2. below, which produce the following 
results: 

Results:
1. [ANG, BAR, BPK, CTN, QGH, QHD, KXX]
2. ['ANG', 'BAR', 'BPK', 'CTN', 'QGH', 'QHD', 'KXX']

Code:
   cursor_from.execute('SELECT * FROM tubestations LIMIT 1000')
   
   stn_list_short = []
   for row in cursor_from:
  if row[4]:
# Station values for database
stn_list_short.append(row[5])

   1. print stn_fields = '[%s]' % ', '.join(map(str, stn_list_short))  
   2. print stn_list_short

Thanks!

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


Re: Difference between these two lists?

2013-01-07 Thread andydtaylor
I think I can answer my own question on reflection the first one is 
actually  a string I think? I was confused by the square brackets around the 
placeholder %s.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calculate Big Number

2013-01-07 Thread Tim Chase

On 01/07/13 18:44, Nac Temha wrote:

How to *quickly* calculate large numbers. For example

(10**25) * (2**50)

11258999068426240L


that's how...just do the math.  For any other sort of answer, you'd 
have to clarify your question.  On my laptop, that operation came 
back as quickly as I could press enter


-tkc





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


Re: Difference between these two lists?

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 12:00 PM,  andydtay...@gmail.com wrote:
 Hi,

 Python newbie here again - this is probably a quick one. What's the 
 difference between the lines I've numbered 1. and 2. below, which produce the 
 following results:
1. print stn_fields = '[%s]' % ', '.join(map(str, stn_list_short))
2. print stn_list_short

Your first line explicitly joins the strings with commas; the second
implicitly calls repr() on the whole list, which does its best to
produce a valid Python literal. Check out the docs on repr() for the
details on that; you'll see different results depending on the content
of the strings, but at very least they'll always be quoted.

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


Re: Difference between these two lists?

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 12:06 PM,  andydtay...@gmail.com wrote:
 I think I can answer my own question on reflection the first one is 
 actually  a string I think? I was confused by the square brackets around the 
 placeholder %s.

That's correct. Your first line is putting square brackets around a
comma-joined list of strings; the second gives the representation of a
list. They happen to be superficially similar.

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


Re: Calculate Big Number

2013-01-07 Thread Nac Temha
Thanks for reply. I wonder how quickly calculate big numbers. Can you
explain me as theoretical? Because this numbers overflow size of integer
and double.


On Tue, Jan 8, 2013 at 3:08 AM, Tim Chase python.l...@tim.thechases.comwrote:

 On 01/07/13 18:44, Nac Temha wrote:

 How to *quickly* calculate large numbers. For example

 (10**25) * (2**50)

 112589990684262400**000L


 that's how...just do the math.  For any other sort of answer, you'd have
 to clarify your question.  On my laptop, that operation came back as
 quickly as I could press enter

 -tkc






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


Re: Difference between these two lists?

2013-01-07 Thread Roy Smith
In article 700d2bd9-e1df-4d38-81c7-77029a36c...@googlegroups.com,
 andydtay...@gmail.com wrote:

 Hi,
 
 Python newbie here again - this is probably a quick one. What's the 
 difference between the lines I've numbered 1. and 2. below, which produce the 
 following results: 
 
 Results:
 1. [ANG, BAR, BPK, CTN, QGH, QHD, KXX]
 2. ['ANG', 'BAR', 'BPK', 'CTN', 'QGH', 'QHD', 'KXX']
 
 Code:
cursor_from.execute('SELECT * FROM tubestations LIMIT 1000')

stn_list_short = []
for row in cursor_from:
   if row[4]:
   # Station values for database
   stn_list_short.append(row[5])
 
1. print stn_fields = '[%s]' % ', '.join(map(str, stn_list_short))  
2. print stn_list_short

Hi Andy,

You should try to reduce this down to some minimal test case.  In this 
case, the database code has nothing to do with it, it's purely a matter 
of how a list of strings is printed.

When you print a list, the repr() of each list element is printed.  The 
repr() of a string includes quotes.  For example:

 print str(foo)
foo
 print repr(foo)
'foo'

I'm not sure what map(str, stn_list_short) is all about.  I'm assuming 
stn_list_short is already a string, so that's a no-op.

In general, the best way to ask about code is to cut-and-paste the exact 
code that you ran.  You didn't run:

1. print stn_fields = '[%s]' % ', '.join(map(str, stn_list_short))  
2. print stn_list_short

because those are syntax errors.  I understand you were just trying to 
annotate your code to make it easier to explain.  A better way to do 
that would be to comment your code, something like:

print stn_fields = '[%s]' % ', '.join(map(str, stn_list_short))  # line 1
print stn_list_short  # line 2

Now you've got something which runs, and can be cut-and-pasted 
unmodified into your posting.  That reduces the chance of confusion.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between these two lists?

2013-01-07 Thread Dave Angel
On 01/07/2013 08:00 PM, andydtay...@gmail.com wrote:
 Hi,

 Python newbie here again - this is probably a quick one. What's the 
 difference between the lines I've numbered 1. and 2. below, which produce the 
 following results: 

 Results:
 1. [ANG, BAR, BPK, CTN, QGH, QHD, KXX]
 2. ['ANG', 'BAR', 'BPK', 'CTN', 'QGH', 'QHD', 'KXX']

 Code:
cursor_from.execute('SELECT * FROM tubestations LIMIT 1000')

stn_list_short = []
for row in cursor_from:
   if row[4]:
   # Station values for database
   stn_list_short.append(row[5])

1. print stn_fields = '[%s]' % ', '.join(map(str, stn_list_short))  
2. print stn_list_short


#2 is easy.  it's just the standard way a list prints itself.  It puts
brackets at begin and end, and then calls repr() on each of the
elements.  Since those elements are str objects, each gets quotes around
it.  Then the list logic adds commas and puts it all together.

In #1, you're doing it by hand.  If you wanted the same result, you'd
have to map the repr, not the str value of each item.

(untested)

.join(map(repr, stn_list_short)



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


Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]

2013-01-07 Thread Steven D'Aprano
On Mon, 07 Jan 2013 22:32:54 +, Oscar Benjamin wrote:

 An example: Earlier today I was looking at some experimental data. A
 simple model of the process underlying the experiment suggests that two
 variables x and y will vary in direct proportion to one another and the
 data broadly reflects this. However, at this stage there is some
 non-normal variability in the data, caused by experimental difficulties.
 A subset of the data appears to closely follow a well defined linear
 pattern but there are outliers and the pattern breaks down in an
 asymmetric way at larger x and y values. At some later time either the
 sources of experimental variation will be reduced, or they will be
 better understood but for now it is still useful to estimate the
 constant of proportionality in order to check whether it seems
 consistent with the observed values of z. With this particular dataset I
 would have wasted a lot of time if I had tried to find a computational
 method to match the line that to me was very visible so I chose the line
 visually.


If you mean:

I looked at the data, identified that the range a  x  b looks linear 
and the range x  b does not, then used least squares (or some other 
recognised, objective technique for fitting a line) to the data in that 
linear range

then I'm completely cool with that. That's fine, with the understanding 
that this is the first step in either fixing your measurement problems, 
fixing your model, or at least avoiding extrapolation into the non-linear 
range.

But that is not fitting a line by eye, which is what I am talking about.

If on the other hand you mean:

I looked at the data, identified that the range a  x  b looked linear, 
so I laid a ruler down over the graph and pushed it around until I was 
satisfied that the ruler looked more or less like it fitted the data 
points, according to my guess of what counts as a close fit

that *is* fitting a line by eye, and it is entirely subjective and 
extremely dodgy for anything beyond quick and dirty back of the envelope 
calculations[1]. That's okay if all you want is to get something within 
an order of magnitude or so, or a line roughly pointing in the right 
direction, but that's all.


[...]
 I also think it would
 be highly foolish to go so far with refusing to eyeball data that you
 would accept the output of some regression algorithm even when it
 clearly looks wrong.

I never said anything of the sort.

I said, don't fit lines to data by eye. I didn't say not to sanity check 
your straight line fit is reasonable by eyeballing it.



[1] Or if your data is so accurate and noise-free that you hardly have to 
care about errors, since there clearly is one and only one straight line 
that passes through all the points.


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


Re: Calculate Big Number

2013-01-07 Thread Tomasz Rola
On Tue, 8 Jan 2013, Nac Temha wrote:

 Hello,
 How to *quickly* calculate large numbers. For example
  (10**25) * (2**50)
 11258999068426240L
 

Um, Karatsuba multiplication?

http://en.wikipedia.org/wiki/Karatsuba_algorithm

Or see what GMP folks are doing:

http://en.wikipedia.org/wiki/GNU_Multi-Precision_Library

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did rm -rif on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calculate Big Number

2013-01-07 Thread Dave Angel
On 01/07/2013 07:44 PM, Nac Temha wrote:
 Hello,
 How to *quickly* calculate large numbers. For example
 (10**25) * (2**50)
 11258999068426240L



Since all of the terms are const, you could just use

print 11258999068426240L

Or if you have some constraints on those numbers, you could preprocess the 
calculation with meatware.

For example, if you wnated   (10**var1) * (var2**var3),  where var1, var2 and 
var3 are  all ints, then you could save some time by doing:
print str(var2**var3)+0*var1

Or you could write C code to do multiprecision arithmetic.  Or ...

What are your constraints?  If you have to calculate an arbitrary expression of 
ints and longs, you'll spend a lot more time typing it in than the computer 
will calculating it.

BTW, if you want a non-trivial answer, you should specify what Python version 
you're targeting.   I arbitrarily chose 2.7 for my response.m


-- 

DaveA

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


Re: Calculate Big Number

2013-01-07 Thread Dave Angel
On 01/07/2013 08:22 PM, Nac Temha wrote:
 Thanks for reply. I wonder how quickly calculate big numbers. Can you
 explain me as theoretical? Because this numbers overflow size of integer
 and double.
Please don't top-post.  It makes the context totally out of order.

Python automatically promotes to long when doing integer arithmetic, and
the numbers grow too big.  And on version 3, there's no distinction. 
floats are not used, or there would be errors.

Your wonder statement is not complete, so I'm not sure what you're
asking.  Could you elaborate?  Are you asking to see the source code for
the python interpreter that's responsible for this?  Or an algorithm
that it might use?  Are you curious in a language-agnostic way how one
might do multiple-precision arithmetic?  I've written arithmetic
packages in PL/I and in BASIC, plus implemented the microcoded math in
one processor.  So, for example, I might explain how one could compute
X**Y when Y is a positive integer, without doing Y-1 multiplies.



-- 

DaveA

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


Re: Calculate Big Number

2013-01-07 Thread Roy Smith
In article mailman.252.1357608154.2939.python-l...@python.org,
 Nac Temha nacctte...@gmail.com wrote:

 Thanks for reply. I wonder how quickly calculate big numbers. Can you
 explain me as theoretical? Because this numbers overflow size of integer
 and double.

Now, that's a good question.  The answer is that Python implements 
multiple-precision arithmetic.  This is an awesome feature, as it means 
you never have to worry about integer overflow again.  A good 
introduction to the subject can be found at

http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]

2013-01-07 Thread Steven D'Aprano
On Tue, 08 Jan 2013 06:43:46 +1100, Chris Angelico wrote:

 On Tue, Jan 8, 2013 at 4:58 AM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 Anyone can fool themselves into placing a line through a subset of non-
 linear data. Or, sadly more often, *deliberately* cherry picking fake
 clusters in order to fool others. Here is a real world example of what
 happens when people pick out the data clusters that they like based on
 visual inspection:

 http://www.skepticalscience.com/images/TempEscalator.gif
 
 And sensible people will notice that, even drawn like that, it's only a
 ~0.6 deg increase across ~30 years. Hardly statistically significant,

Well, I don't know about sensible people, but magnitude of an effect 
has little to do with whether or not something is statistically 
significant or not. Given noisy data, statistical significance relates to 
whether or not we can be confident that the effect is *real*, not whether 
it is a big effect or a small effect.

Here's an example: assume that you are on a fixed salary with a constant 
weekly income. If you happen to win the lottery one day, and consequently 
your income for that week quadruples, that is a large effect that fails 
to have any statistical significance -- it's a blip, not part of any long-
term change in income. You can't conclude that you'll win the lottery 
every week from now on.

On the other hand, if the government changes the rules relating to tax, 
deductions, etc., even by a small amount, your weekly income might go 
down, or up, by a single dollar. Even though that is a tiny effect, it is 
*not* a blip, and will be statistically significant. In practice, it 
takes a certain number of data points to reach that confidence level. 
Your accountant, who knows the tax laws, will conclude that the change is 
real immediately, but a statistician who sees only the pay slips may take 
some months before she is convinced that the change is signal rather than 
noise. With only three weeks pay slips in hand, the statistician cannot 
be sure that the difference is not just some accounting error or other 
fluke, but each additional data point increases the confidence that the 
difference is real and not just some temporary aberration.

The other meaning of significant has nothing to do with statistics, and 
everything to do with a difference is only a difference if it makes a 
difference. 0.2° per decade doesn't sound like much, not when we 
consider daily or yearly temperatures that typically have a range of tens 
of degrees between night and day, or winter and summer. But that is 
misunderstanding the nature of long-term climate versus daily weather and 
glossing over the fact that we're only talking about an average and 
ignoring changes to the variability of the climate: a small increase in 
average can lead to a large increase in extreme events.


 given that weather patterns have been known to follow cycles at least
 that long.

That is not a given. Weather patterns don't last for thirty years. 
Perhaps you are talking about climate patterns? In which case, well, yes, 
we can see a very strong climate pattern of warming on a time scale of 
decades, with no evidence that it is a cycle.

There are, of course, many climate cycles that take place on a time frame 
of years or decades, such as the North Atlantic Oscillation and the El 
Nino Southern Oscillation. None of them are global, and as far as I know 
none of them are exactly periodic. They are noise in the system, and 
certainly not responsible for linear trends.



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


Re: Calculate Big Number

2013-01-07 Thread Dave Angel
(forwarding the private reply to the group)

On 01/07/2013 09:03 PM, Nac Temha wrote:
 Thanks. I using version 2.7 .I want to understand how to handling big
 number. Just  want to know logic.  Without going into further details but I
 want to learn logic of this issue. How to keep datas in python? Using data
 structure? and datas how to handling for calculating?
 
 

Since I don't understand your questions, I'll make some guesses.  If
these don't cover it, please reword your questions.

I'll assume you do NOT want internal details of how the python
interpreter manages it.   I'll assume you DO want to know how to write
your python program so that as much accuracy as possible is used in the
calculations.

First comment - as soon as you introduce a floating point (non-integer)
value into the expression, you have the potential of losing precision.
In general, when doing mixed arithmetic, python will convert the result
to float.  Lots can be written (and has been written) about floats,
Decimals, quantization and rounding.  I'm again assuming you're NOT
asking about these.

In Python 2.7, there are two kinds of integers, int and long.  An int is
limited to some processor-specific size, usually 32 or 64 bits.  A long
has no practical limit, though after a few hundred million digits, it
gets pretty memory hungry and piggishly slow.  A long is NOT related to
the C type of the same name.

If you have an integer in your source code that's larger than that
limit, it'll automatically be promoted to long.

If you want to see the type of a particular object, you can use
type(myobj).   For example,

print type(2397493749328734972349873)
will print: type 'long'

If you add, subtract, multiply or ** two int objects, and the result is
too big for an int, it'll automatically be promoted to long.

If you divide two integers with /  the result is floored.  Thus the
result is an integer.  That changes in Python 3, where you can get this
result with //.

If you call some library function on a long, it may or may not be able
to handle it, check the docs.  But in your own code, it's pretty easy to
keep things clean.

If you have more questions, please be specific.

-- 

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


Re: Difference between these two lists?

2013-01-07 Thread andydtaylor
Thanks, I think I'm clear now. 

I guess (map(str, stn_list)) was all about how to make a string starting with 
integers. I picked that up and began using it without realising it was over 
catering for a list already containing strings, and join(stn_list) was really 
all I required.

Repr and Eval I think I get. Eval certainly. That's a familiar concept, and one 
I hope to use tomorrow to feed a line to psycopg2. 

I might have opened a can of worms on map and repr though... I'll do some more 
reading tomorrow.

Top tip on the code annotation, I didn't really think that through.

Thanks again,

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


Re: Difference between these two lists?

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 1:21 PM,  andydtay...@gmail.com wrote:
 Repr and Eval I think I get. Eval certainly. That's a familiar concept, and 
 one I hope to use tomorrow to feed a line to psycopg2.

I hope not. Why do you need eval? It's extremely dangerous.

Chances are there's a better way to do it; if your users are entering
strings like

['Foo', 'Bar']

and you want them to be interpreted as lists, then you can get a much
safer function ast.literal_eval - it's equivalent to eval, but (as the
name suggests) works only with literals, so you can't call functions
etc. But even that may be overkill, depending on what you actually
need.

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


FYI - wiki.python.org compromised

2013-01-07 Thread Brian Curtin
On December 28th, an unknown attacker used a previously unknown remote
code exploit on http://wiki.python.org/. The attacker was able to get
shell access as the moin user, but no other services were affected.

Some time later, the attacker deleted all files owned by the moin
user, including all instance data for both the Python and Jython
wikis. The attack also had full access to all MoinMoin user data on
all wikis. In light of this, the Python Software Foundation encourages
all wiki users to change their password on other sites if the same one
is in use elsewhere. We apologize for the inconvenience and will post
further news as we bring the new and improved wiki.python.org online.

If you have any questions about this incident please contact
jnol...@python.org. Thank you for your patience.
-- 
http://mail.python.org/mailman/listinfo/python-list


how to download internet files by python ?

2013-01-07 Thread iMath
for example ,if I want to download this file ,how to implement the download 
functionality by python ?

http://down.51voa.com/201208/se-ed-foreign-students-friends-16aug12.mp3

as for  download speed ,of course ,the fast ,the better ,so how to implement it 
?

It would be better to show me an example :) thanks !!!
-- 
http://mail.python.org/mailman/listinfo/python-list


How to get the selected text of the webpage in chrome through python ?

2013-01-07 Thread iMath
How to get the selected text of the webpage in chrome through python ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to download internet files by python ?

2013-01-07 Thread Cameron Simpson
On 07Jan2013 20:19, iMath redstone-c...@163.com wrote:
| for example ,if I want to download this file ,how to implement the download 
functionality by python ?
| 
| http://down.51voa.com/201208/se-ed-foreign-students-friends-16aug12.mp3
| 
| as for  download speed ,of course ,the fast ,the better ,so how to implement 
it ?
| It would be better to show me an example :) thanks !!!

Look at urllib2.
-- 
Cameron Simpson c...@zip.com.au

If God had intended Man to fly, He would have given him more money.
- Jeff Cauhape, cauh...@twg.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to download internet files by python ?

2013-01-07 Thread Rodrick Brown
On Mon, Jan 7, 2013 at 11:19 PM, iMath redstone-c...@163.com wrote:

 for example ,if I want to download this file ,how to implement the
 download functionality by python ?

 http://down.51voa.com/201208/se-ed-foreign-students-friends-16aug12.mp3

 as for  download speed ,of course ,the fast ,the better ,so how to
 implement it ?

 It would be better to show me an example :) thanks !!!
 --
 http://mail.python.org/mailman/listinfo/python-list


#!/usr/bin/python
import urllib2
if __name__ == '__main__':
fileurl='
http://down.51voa.com/201208/se-ed-foreign-students-friends-16aug12.mp3'

mp3file = urllib2.urlopen(fileurl)
with open('outfile.mp3','wb') as output:
output.write(mp3file.read())
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to download internet files by python ?

2013-01-07 Thread Roy Smith
In article mailman.259.1357620254.2939.python-l...@python.org,
 Cameron Simpson c...@zip.com.au wrote:

 On 07Jan2013 20:19, iMath redstone-c...@163.com wrote:
 | for example ,if I want to download this file ,how to implement the download 
 | functionality by python ?
 | 
 | http://down.51voa.com/201208/se-ed-foreign-students-friends-16aug12.mp3
 | 
 | as for  download speed ,of course ,the fast ,the better ,so how to 
 | implement it ?
 | It would be better to show me an example :) thanks !!!
 
 Look at urllib2.

Even better, look at requests 
(http://docs.python-requests.org/en/latest/).  There's nothing you can 
do with requests that you can't do with urllib2, but the interface is a 
whole lot easier to work with.
-- 
http://mail.python.org/mailman/listinfo/python-list


comparison between non-comparable objects

2013-01-07 Thread Kelvin Li
The language reference says:

...the choice whether one object [of built-in type] is considered
smaller or larger than another one is made arbitrarily...

but that seems to be Python 2 behavior; Python 3 apparently raises a
TypeError. Does the documentation need updating?

Thanks,
Kelvin

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


Re: comparison between non-comparable objects

2013-01-07 Thread Dave Angel
On 01/08/2013 12:28 AM, Kelvin Li wrote:
 The language reference says:

 ...the choice whether one object [of built-in type] is considered
 smaller or larger than another one is made arbitrarily...

When quoting some online source, please give a reference link. It took
me a while to find the following page with your quote in it:


http://docs.python.org/3.3/reference/expressions.html
http://docs.python.org/3.3/reference/expressions.htm
   in section 6.9  Comparisons

 but that seems to be Python 2 behavior; Python 3 apparently raises a
 TypeError. Does the documentation need updating?


That sentence is correct in context.  The bullet items there are labeled
Comparison of objects of the same type...  And the particular bullet
also qualifies the type of the two objects being compared:Most
other objects of built-in types...



Earlier in the same section, it considers the case of comparing objects
of DIFFERENT type.

 while the , , = and = operators raise a TypeError
http://docs.python.org/3.3/library/exceptions.html#TypeError when
comparing objects of different types that do not implement these
operators for the given pair of types


-- 

DaveA

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


Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 1:06 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 given that weather patterns have been known to follow cycles at least
 that long.

 That is not a given. Weather patterns don't last for thirty years.
 Perhaps you are talking about climate patterns?

Yes, that's what I meant. In any case, debate about global warming is
quite tangential to the point about statistical validity; it looks
quite significant to show a line going from the bottom of the graph to
the top, but sounds a lot less noteworthy when you see it as a
half-degree increase on about (I think?) 30 degrees, and even less
when you measure temperatures in absolute scale (Kelvin) and it's half
a degree in three hundred. Those are principles worth considering,
regardless of the subject matter. If your railway tracks have widened
by a full eight millimeters due to increased pounding from heavier
vehicles travelling over it, that's significant and dangerous on
HO-scale model trains, but utterly insignificant on 5'3 gauge.

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


Re: comparison between non-comparable objects

2013-01-07 Thread Kelvin Li
 When quoting some online source, please give a reference link. It took
 me a while to find the following page with your quote in it:
 
 
 http://docs.python.org/3.3/reference/expressions.html
 http://docs.python.org/3.3/reference/expressions.htm
in section 6.9  Comparisons

Sorry about that. Thanks for finding the link.

  but that seems to be Python 2 behavior; Python 3 apparently raises a
  TypeError. Does the documentation need updating?
 
 
 That sentence is correct in context.  The bullet items there are labeled
 Comparison of objects of the same type...  And the particular bullet
 also qualifies the type of the two objects being compared:Most
 other objects of built-in types...

Got it, I was confusing built-in types with built-in functions--I
incorrectly thought object(), for example, returned an object of a
built-in type, and was behaving differently in Python 2 and 3:

object()  object()

Thanks,
Kelvin

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


[issue9685] tuples should remember their hash value

2013-01-07 Thread Mark Dickinson

Mark Dickinson added the comment:

Given the responses so far, I suggest closing this as rejected.

--
nosy: +mark.dickinson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9685
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16866] libainstall doesn't create $(BINDIR) directory

2013-01-07 Thread Benno Leslie

Benno Leslie added the comment:

In a similar manner the bininstall target relies on $(LIBPC), but does not 
create that.

This makes me consider if the libainstall target should be installing 
pkg-config sciprt at all (and whether bininstall should be installing the .pc 
files).

It is hard for me to determine what the exact intended goals of each of these 
targets is, so I can't really come up with the right fix. Naively for both 
targets ensuring that the directory exists solves the symptom, but to be it 
looks like there is probably a greater underlying thing to determine here.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16866
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9685] tuples should remember their hash value

2013-01-07 Thread Christian Heimes

Christian Heimes added the comment:

I'm not too worried about the slightly increased memory usage. For example one 
of our largest application instances consumes about 8 GB memory right now. It 
has just about 22k tuples in gc.get_objects(). An additional Py_hash_t in 
tuple's struct would increase the memory usage by less than 200kB.

I've attached a simple patch.

--
keywords: +patch
nosy: +christian.heimes
stage: needs patch - patch review
Added file: http://bugs.python.org/file28605/tuplehash.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9685
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16883] --enable-shared during configure forces 2.7.3 to build as 2.7.2+ on Ubuntu 11.10

2013-01-07 Thread Ned Deily

Ned Deily added the comment:

You need to be careful when using a Python with --enable-shared to ensure that 
the correct dynamic libraries are being used at execution time.  Normally, 
after a make, you use make install to install the Python executable and the 
shared library into the configured locations, by default in /usr/local.  If you 
try to run a --enable-shared python executable from its build directory, you'll 
need to tell the dynamic loader where to find the shared library, i.e. the 
build directory itself. One way to do that is to use the LD_LIBRARY_PATH 
environment variable.  Otherwise, the dynamic loader will search the standard 
paths, like /usr/local/lib/ and /usr/lib/ for a shared library with the proper 
name (like libpython2.7.so.1.0).  If there is an older Python already installed 
with that name and if the ABI hasn't changed too much, you may be lucky and it 
will load and run.  In your example, you undoubtedly had a Python 2.7.2+ 
already installed in either /usr or /usr/local.  In this example, I
  have a shared 2.7.3rc2 installed in /usr/bin and am building a 2.7.3:

$ ./configure --enable-shared ; make
$ /usr/bin/python2.7 -V
Python 2.7.3rc2
$ ./python -V
Python 2.7.3rc2
$ LD_LIBRARY_PATH=. ./python -V
Python 2.7.3

The make clean and rebuild step you show makes no difference by itself.  
Without installing or setting the library search path, the older installed 
library will still be picked up.  What likely happened is that you did a make 
install in between the two steps.

--
nosy: +ned.deily
resolution:  - invalid
stage:  - committed/rejected
status: open - closed
type: compile error - 

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16883
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16853] add a Selector to the select module

2013-01-07 Thread Charles-François Natali

Charles-François Natali added the comment:

 Also notice the need for a third constant, SELECT_CONNECT.  For details see 
 the class WindowsPollPollster in the Tulip code.

I'll trust Richard on all Windows matter, so if you need a
SELECT_CONNECT constant, I'll expose one.

 However, two Tulip tests are now failing:

I can't reproduce those failures on Linux (I had to adapt the
hostnames because I'm at work and my test machine can't access the
internet, but otherwise everything is the same). All tests pass with
select, poll and epoll.

Note that I had to fix a typo in the patch: EPollSelector - EpollSelector.

 - tulip.events_test.PollEventLoopTests.testCreateSslTransport fails with 
 spurious file descriptors returned by poll() that aren't in the _fd_to_key 
 dict (but the corresponding test with Select passes)

 The first failure has this traceback:

 Traceback (most recent call last):
   File /Users/guido/tulip/tulip/selectors.py, line 178, in _key_from_fd
 return self._fd_to_key[fd]
 KeyError: 0

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File /Users/guido/tulip/tulip/events_test.py, line 216, in 
 testCreateSslTra\
 nsport
 el.run()
   File /Users/guido/tulip/tulip/unix_events.py, line 120, in run
 self._run_once()
   File /Users/guido/tulip/tulip/unix_events.py, line 592, in _run_once
 event_list = self._selector.select(timeout)
   File /Users/guido/tulip/tulip/selectors.py, line 255, in select
 key = self._key_from_fd(fd)
   File /Users/guido/tulip/tulip/selectors.py, line 180, in _key_from_fd
 raise RuntimeError(No key found for fd {}.format(fd))
 RuntimeError: No key found for fd 0

 (But the fd value varies -- sometimes it is -2, sometimes a large number.)

This failure is really weird, because the file descriptor is really
just the value returned by poll.poll(): I don't know how this could
possibly ever be negative, unless some sort of overflow in the
poll.poll() code itself?

I can however see why the previous version wouldn't fail:

for fd, flags in self._poll.poll(msecs):
if flags  ~select.POLLOUT:
if fd in self.readers:
events.append(self.readers[fd])
if flags  ~select.POLLIN:
if fd in self.writers:
events.append(self.writers[fd])


If a spurious fd is reported, it's silently ignored.

The second test runs fine on Linux, and from a cursory look, I don't
see how it could fail (the socket should be reported as write ready
upon ECONNREFUSED).

I'll try running the exact test case with the same hostnames from
home, but I doubt it'll make a difference, so maybe it's really OS-X
specific (if there's strace/dtrace on OS-X, it'll help see what's
going on).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16853
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16882] Python 2.7 has 73 files with hard references to /usr/local when building on *NIX

2013-01-07 Thread Ned Deily

Ned Deily added the comment:

Thanks for your suggestion.  However, the issue you've created is too wide in 
scope to be actionable.  As you note, just because the string /usr/local 
appears in a file within the Python source distribution does not indicate a 
problem.  Many of the cites are in documentation or examples where it is noted 
or understood that the correct path will need to be supplied or is supplied 
when the file is actually built and installed.

The one real related issue I am aware of is that the main setup.py, which is 
used to build the standard library components, does have some hardwired sets of 
paths, usually including /usr/local, to find necessary third-party libraries 
and setup.py does not always provide a consistent way to augment those paths.  
This is also an issue for cross-compiling Python for other environments.  There 
are various issues open regarding this, for example, Issue5575 Add env vars 
for controlling building sqlite, hashlib and ssl.  I would suggest 
contributing to those issues by creating or reviewing and testing existing 
patches.  Also note that Python 2.7.x is open for bug fixes; new features are 
generally only accepted for the next major release, currently expected to be 
Python 3.4.  Unless there are more specific items that are not already covered 
in another issue, I am inclined to close this one.

--
nosy: +ned.deily
status: open - pending
type: compile error - enhancement

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16882
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9685] tuples should remember their hash value

2013-01-07 Thread Georg Brandl

Georg Brandl added the comment:

Still, actual benefits in some kind of benchmark will be needed to show that 
this is not a premature optimization.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9685
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16853] add a Selector to the select module

2013-01-07 Thread Charles-François Natali

Charles-François Natali added the comment:

 The second test runs fine on Linux, and from a cursory look, I don't
 see how it could fail (the socket should be reported as write ready
 upon ECONNREFUSED).

Hum, thinking about it, I wonder is OS-X doesn't report POLLPRI or
some other esoteric event in case of ECONNREFUSED...

Could you try the patch attached?

--
Added file: http://bugs.python.org/file28606/selector_poll_events.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16853
___--- tulip/selectors.py.orig 2013-01-07 11:33:56.035521000 +0100
+++ tulip/selectors.py  2013-01-07 11:46:04.351542000 +0100
@@ -242,15 +242,10 @@
 ready = []
 for fd, event in self._poll.poll(timeout):
 events = 0
-if event  (POLLERR|POLLNVAL):
-# in case of error, signal read and write ready
-events |= SELECT_IN|SELECT_OUT
-else:
-if event  (POLLIN|POLLHUP):
-# in case of hangup, signal read ready
-events |= SELECT_IN
-if event  POLLOUT:
-events |= SELECT_OUT
+if event  ~POLLOUT:
+events |= SELECT_IN
+if event  ~POLLIN:
+events |= SELECT_OUT
 
 key = self._key_from_fd(fd)
 ready.append((key.fileobj, events, key.data))
@@ -282,15 +277,10 @@
 ready = []
 for fd, event in self._epoll.poll(timeout, self.registered_count()):
 events = 0
-if event  EPOLLERR:
-# in case of error, signal read and write ready
-events |= SELECT_IN|SELECT_OUT
-else:
-if event  (EPOLLIN|EPOLLHUP):
-# in case of hangup, signal read ready
-events |= SELECT_IN
-if event  EPOLLOUT:
-events |= SELECT_OUT
+if event  ~EPOLLOUT:
+events |= SELECT_IN
+if event  ~EPOLLIN:
+events |= SELECT_OUT
 
 key = self._key_from_fd(fd)
 ready.append((key.fileobj, events, key.data))
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10156] Initialization of globals in unicodeobject.c

2013-01-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here are patches for all four Python versions. They fixes possible usage of the 
followed non-initialized global variables: free_list, numfree, interned, 
unicode_empty, static_strings, unicode_latin1, bloom_linebreak, 
unicode_default_encoding.

--
Added file: http://bugs.python.org/file28607/unicode_globals-2.7.patch
Added file: http://bugs.python.org/file28608/unicode_globals-3.2.patch
Added file: http://bugs.python.org/file28609/unicode_globals-3.3.patch
Added file: http://bugs.python.org/file28610/unicode_globals-3.4.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10156
___diff -r 0f24c65fb7e5 Objects/unicodeobject.c
--- a/Objects/unicodeobject.c   Sat Jan 05 07:37:47 2013 +0200
+++ b/Objects/unicodeobject.c   Mon Jan 07 13:26:16 2013 +0200
@@ -93,15 +93,26 @@
 #endif
 
 /* Free list for Unicode objects */
-static PyUnicodeObject *free_list;
-static int numfree;
+static PyUnicodeObject *free_list = NULL;
+static int numfree = 0;
 
 /* The empty Unicode object is shared to improve performance. */
-static PyUnicodeObject *unicode_empty;
+static PyUnicodeObject *unicode_empty = NULL;
+
+#define _Py_RETURN_UNICODE_EMPTY()  do {\
+if (unicode_empty != NULL)  \
+Py_INCREF(unicode_empty);   \
+else {  \
+unicode_empty = _PyUnicode_New(0);  \
+if (unicode_empty != NULL)  \
+Py_INCREF(unicode_empty);   \
+}   \
+return (PyObject *)unicode_empty;   \
+} while (0)
 
 /* Single character Unicode strings in the Latin-1 range are being
shared as well. */
-static PyUnicodeObject *unicode_latin1[256];
+static PyUnicodeObject *unicode_latin1[256] = {NULL};
 
 /* Default encoding to use and assume when NULL is passed as encoding
parameter; it is initialized by _PyUnicode_Init().
@@ -110,7 +121,7 @@
PyUnicode_GetDefaultEncoding() APIs to access this global.
 
 */
-static char unicode_default_encoding[100];
+static char unicode_default_encoding[100 + 1] = ascii;
 
 /* Fast detection of the most frequent whitespace characters */
 const unsigned char _Py_ascii_whitespace[] = {
@@ -204,7 +215,7 @@
 
 #define BLOOM_MASK unsigned long
 
-static BLOOM_MASK bloom_linebreak;
+static BLOOM_MASK bloom_linebreak = ~(BLOOM_MASK)0;
 
 #define BLOOM_ADD(mask, ch) ((mask |= (1UL  ((ch)  (BLOOM_WIDTH - 1)
 #define BLOOM(mask, ch) ((mask   (1UL  ((ch)  (BLOOM_WIDTH - 1)
@@ -448,10 +459,8 @@
 if (u != NULL) {
 
 /* Optimization for empty strings */
-if (size == 0  unicode_empty != NULL) {
-Py_INCREF(unicode_empty);
-return (PyObject *)unicode_empty;
-}
+if (size == 0)
+_Py_RETURN_UNICODE_EMPTY();
 
 /* Single character Unicode objects in the Latin-1 range are
shared when using this constructor */
@@ -497,10 +506,8 @@
 if (u != NULL) {
 
 /* Optimization for empty strings */
-if (size == 0  unicode_empty != NULL) {
-Py_INCREF(unicode_empty);
-return (PyObject *)unicode_empty;
-}
+if (size == 0)
+_Py_RETURN_UNICODE_EMPTY();
 
 /* Single characters are shared when using this constructor.
Restrict to ASCII, since the input must be UTF-8. */
@@ -1162,13 +1169,10 @@
 }
 
 /* Convert to Unicode */
-if (len == 0) {
-Py_INCREF(unicode_empty);
-v = (PyObject *)unicode_empty;
-}
-else
-v = PyUnicode_Decode(s, len, encoding, errors);
-
+if (len == 0)
+_Py_RETURN_UNICODE_EMPTY();
+
+v = PyUnicode_Decode(s, len, encoding, errors);
 return v;
 
   onError:
@@ -1381,7 +1385,7 @@
 Py_DECREF(v);
 strncpy(unicode_default_encoding,
 encoding,
-sizeof(unicode_default_encoding));
+sizeof(unicode_default_encoding) - 1);
 return 0;
 
   onError:
@@ -8838,8 +8842,6 @@
 
 void _PyUnicode_Init(void)
 {
-int i;
-
 /* XXX - move this array to unicodectype.c ? */
 Py_UNICODE linebreak[] = {
 0x000A, /* LINE FEED */
@@ -8853,15 +8855,10 @@
 };
 
 /* Init the implementation */
-free_list = NULL;
-numfree = 0;
 unicode_empty = _PyUnicode_New(0);
 if (!unicode_empty)
 return;
 
-strcpy(unicode_default_encoding, ascii);
-for (i = 0; i  256; i++)
-unicode_latin1[i] = NULL;
 if (PyType_Ready(PyUnicode_Type)  0)
 Py_FatalError(Can't initialize 'unicode');
 
@@ -8906,15 +8903,11 @@
 {
 int i;
 
-Py_XDECREF(unicode_empty);
-unicode_empty = NULL;
-
-for (i = 0; i  256; i++) {
-if (unicode_latin1[i]) {
-Py_DECREF(unicode_latin1[i]);
-   

[issue10156] Initialization of globals in unicodeobject.c

2013-01-07 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
stage: commit review - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10156
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16884] logging handler automatically added starting in 3.2+

2013-01-07 Thread Chris Jerdonek

New submission from Chris Jerdonek:

Starting in 3.2, the logging module no longer outputs the following message 
when logging and no handlers are configured for the root logger:

log = logging.getLogger()
log.error('test')

'No handlers could be found for logger root'

However, I can't seem to find any version-changed about this in the docs.  The 
code change may be from this commit: c86dc2bd3ae8

Incidentally, I also noticed that three logging paragraphs begin with PLEASE 
NOTE:  Those should probably be changed to .. note:: etc.

--
assignee: docs@python
components: Documentation
keywords: easy
messages: 179257
nosy: chris.jerdonek, docs@python, vinay.sajip
priority: normal
severity: normal
status: open
title: logging handler automatically added starting in 3.2+
type: behavior
versions: Python 3.2, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16884
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16850] Add x mode to open(): close-and-exec (O_CLOEXEC) / O_NOINHERIT

2013-01-07 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
title: Atomic open + close-and-exec - Add x mode to open(): close-and-exec 
(O_CLOEXEC) / O_NOINHERIT

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16850
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16850] Add x mode to open(): close-and-exec (O_CLOEXEC) / O_NOINHERIT

2013-01-07 Thread STINNER Victor

STINNER Victor added the comment:

Oh, my patch doesn't check fcntl() error code.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16850
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16883] --enable-shared during configure forces 2.7.3 to build as 2.7.2+ on Ubuntu 11.10

2013-01-07 Thread Isaac (.ike) Levy

Isaac (.ike) Levy added the comment:

Ned, absolutely correct, thank you!

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16883
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2013-01-07 Thread Nick Coghlan

Nick Coghlan added the comment:

To clarify the vague allusion in my last comment, Ron's suggestion was along 
the lines of creating a dis.Bytecode object that encapsulated everything the 
dis module can figure out about a piece of compiled code.

That would mean exposing the kind of info reported in a string by 
dis.code_info() as attributes/properties, and have the proposed get_opinfo() 
be the __iter__ method on the disassembled Bytecode objects.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11816
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16882] Python 2.7 has 73 files with hard references to /usr/local when building on *NIX

2013-01-07 Thread Isaac (.ike) Levy

Isaac (.ike) Levy added the comment:

Hi Ned,

Thanks.  Your logic is rational here, I'll close it, and open another if I can 
carve out time to attack this with an appropriate patch for setup.py - to 
attempt resolution of the 3rd party library build issues.

However, off the top of your head if you know of any more related tickets, 
(like Issue5575), I'd love to know- I'll cull through to try to find as many 
related bug reports as possible to get a feel for what people have tried.

Best,
.ike

--
resolution:  - wont fix
status: pending - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16882
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16882] Python 2.7 has 73 files with hard references to /usr/local when building on *NIX

2013-01-07 Thread Isaac (.ike) Levy

Changes by Isaac (.ike) Levy ike.l...@axialmarket.com:


--
resolution: wont fix - duplicate

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16882
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   3   >