PyOhio 2013 Call For Proposals Deadline Almost Here (June 1)!

2013-05-27 Thread brian . costlow
PyOhio 2013, the annual Python programming conference for Ohio and the 
surrounding region, will take place Saturday, July 27th, and Sunday, July 28th, 
2013 at the Ohio Union, The Ohio State University in Columbus, Ohio.

You can read more about the conference at http://pyohio.org. If you have 
questions about proposals, please email c...@pyohio.org. You can also contact 
the PyOhio organizers at pyohio-organiz...@python.org.

PyOhio invites all interested people to submit proposals for scheduled talks, 
tutorials, and panels. All topics of interest to Python programmers will be 
considered. Standard presentation talk slots will be 40 minutes plus a 10 
minute question-and-answer period. Tutorial slots will be 110 minutes long. 

The deadline to submit a proposal is June 1st.

*Who Should Submit a Proposal?

You. Your friends. Your friends' friends. Anyone with any level of Python 
knowledge is a candidate for a great topic at this conference. As we get 
attendees of all kinds, we need speakers of all kinds. In all ways and manners, 
we try to assemble the most diverse conference we can, and we do that with your 
help.

Whether you got started with Python last month or you've been around for 20 
years, we think you've got something to share. The Python community is stronger 
than ever and we're still reaching new areas, new industries, and new users. Be 
a part of growing Python by helping us change the future.

In particular, we welcome submissions from people that have never done a talk 
before! And if you want help preparing a talk, let us know! Volunteers are 
eager to help new people do talks.

You can submit more than one proposal.

*What should I talk about?

Anything to do with Python. Teach us about your favorite standard library 
module, or your favorite external library or framework. Show us something cool 
you built with Python. Science and data modeling. Web apps. Finance. Testing. 
Big data. DevOps. Integration with other languages. 

Do you want to work on a talk, but don't have any ideas? The topics below are 
up for grabs. Several people could easily work together on each one. Please 
take these ideas and stretch it out or focus on just one part of it or do 
whatever else you want.

Parallelism shootout: threads vs multiple processes vs libevent.

Walk through porting a library from python 2 to python 3

Python newbies. If you've programmed in another language first, Intro to Python 
for X Programmers, where X is Java, JS, C, PHP etc. If you're entirely new to 
programming, a short talk about your journey learning with Python would be 
great.

We're still looking for someone to do an intro to Python tutorial for adults 
this year. Hint.

*To Submit your proposal.

Sign up for an account on the PyOhio website.

Fill out a speaker profile. After that, you'll be able to submit a proposal. 
Pick talk or tutorial, and then describe your talk. You can edit stuff later, 
so don't over-think it.

Regularly check your email for questions from the reviewers.

*Keynote and Young Coder.

We are thrilled to announce that Brandon Craig Rhodes will be this year's 
keynote speaker.

Brandon has been a frequent speaker and contributor at PyCon, PyOhio, COhPy, 
and in his own words: everywhere from the middle of Arkansas to the country of 
Poland.

http://rhodesmill.org/brandon/

He is co-author of The Essentials of Python Network Programming, and author of 
a number of Python open source packages.

https://bitbucket.org/brandon

Also, Katie Cunningham will be giving an intro to Python class for young people 
12-18 years old (7th-12th grade). This is a version of the Young Coder class 
she and Barbara Shaurette gave at PyCon this year. 

https://us.pycon.org/2013/events/letslearnpython/

*PyCamp

PyCamp is a one-week, intensive, ultra-low-cost Python boot camp for beginners. 
It was developed by a Python user group and has been given to over 1000 
students worldwide. Proceeds from PyCamps are used to sponsor Python community 
activities like PyOhio. PyCamp is taking place July 22-26 in the Ohio Union, 
the week before PyOhio weekend. Registration is open.

http://trizpug.org/boot-camp/pyohio13/

*Register for PyOhio

Registration for PyOhio is now open.

PyOhio remains 100% free to attend. Just sign up for the free registration so 
we can get a head count. Or, if you want the T-Shirt, sign up for the paid 
ticket to get your shirt. (But don't do both!)

http://pyohio.org/registration/

*Hotel(s)

We have a discount room block at the Blackwell, right on OSU's campus for 
$120.00 a night. There are a few rooms blocked for the whole week for any 
out-of-towners going to PyCamp as well. Just tell them you are coming for 
PyOhio.

http://www.theblackwell.com/

If it fills up, here are some other nearby hotels:

http://www.hipmunk.com/hotels/Columbus-OH#!dates=Jul26,Jul28

Hope to see you all at the conference!

The 2013 PyOhio Organizing Committee
-- 

PyModel 1.0: model-based testing in Python

2013-05-27 Thread jon . p . jacky

PyModel v 1.0 is released.

PyModel is a model-based testing framework for Python.  In model-based
testing, you code a model that can generate as many test cases as
needed; the model also checks the test outcomes.  In the samples
included with PyModel, there are models and test scripts for network
sockets, a communication protocol, embedded controllers, some data
structures, a multithreaded application, and a web application.
PyModel also includes an analyzer for validating models, visualizing
their behavior, and checking their safety properties.

Earlier public releases were versions 0.80 in Jan 2010, 0.85 in Mar
2010, and 0.90 in July 2011.  Since July 2011 ongoing work has been
available at GitHub: https://github.com/jon-jacky/PyModel/ PyModel can
also be downloaded from PyPI http://pypi.python.org/pypi/PyModel or
the author's web page at http://staff.washington.edu/jon/pymodel/www/

This release is called version 1.0 because it includes all of the
features considered in the original project plan.  (Development and
maintenance will continue beyond this release.)

Version 1.0 adds new functionality:

- The PyModel Tester pmt supports observable actions and asynchronous
  steppers, to handle event-driven systems and nondeterminism.

- The PyModel Analyzer pma performs safety analysis by checking state
  invariants.  The PyModel Graphics program pmg indicates unsafe states
  in the generated graphs.

- The new PyModel Viewer command pmv combines the functionality of the
  PyModel Analyzer pma, the PyModel Graphics program pmg, and the
  Graphviz dot program in a single command, for convenience and
  brevity.

- The options to include or exclude actions, -a and -e, are now
  supported for FSMs and TestSuites as well as Model Programs, so you
  can use the command line to select which actions to include in your
  analyses or tests, even when you compose model programs with
  scenario machines.

- The tester pmt provides a timeout option to specify that the test
  fails if the implementation does not respond within a given
  deadline.  (This option might not work on Windows.)

- The PyModel programs pma, pmg, pmt, and pmv can be run from the
  command line without the .py extension, like any other command.
  You can just type pmt ... , you no longer have to type pmt.py ...

- The regression testing command tdiff replaces clogdiff.  It works
  the same - this is just a renaming.  The clogdiff command is
  retained in this version for backward compatibility, but is now
  deprecated.

- The new command tclean removes test output files from the
  current directory.

- The revised setup.py now supports the install argument, to
  optionally install the PyModel python modules and commands in system
  directories.  Now PyModel can be installed using distutils
  (... setup.py install ...) or pip.

Version 1.0 adds a new sample and revises all the others:

- The completely rewritten Socket sample includes new asynchronous
  steppers (test harnesses) that show how to support asynchrony and
  nondeterminism using the select function, or alternatively, using
  threads.  The Socket sample also includes new simulators that can
  optionally replace the the Python standard library socket and select
  modules, to demonstrate greater nondeterminism and transmission
  errors.

- The new safety sample demonstrates state invariants and safety analysis.

- There are new fsmpy/ and svg/ directories in each sample that
  contain FSM modules and SVG graphics files generated by the commands
  in the test scripts.

- Many sample test scripts (test*.py modules) have been revised and
  the corresponding reference output (*.ref files) has been
  regenerated.

Version 1.0 adds much new documentation and revises the rest:

- There are new README.md (Markdown format) files in PyModel in most
  top-level directories below PyModel.

- The new README.md in the samples directory briefly describes every
  sample.  The new README.md in each sample directory explains that
  sample in more detail, and describes every file in that sample.

- The documentation in the notes directory has been expanded and
  brought up to date.  There are new and revised .txt files. Some .txt
  files have been replaced by .md (Markdown format) files.

- The web pages in the www directory have been expanded and brought up
  to date.  The content in these pages is drawn from .md files
  and .txt files in other PyModel directories.

Version 1.0 reorganizes some code and directory structure:

- There is a new bin directory for commands and scripts, separated
  from the pymodel directory for Python modules.

- There is a new model.py module that contains the Model base class
  for the ModelProgram, FSM, TestSuite classes.

Version 1.0 makes some bug fixes:

- The programs no longer crash when a parameter generator is missing.
  Now they issue a helpful error message and exit.

- The pmt program cancels the timeout when a timeout was requested but
  did not expire.

- When 

Re: Ldap module and base64 oncoding

2013-05-27 Thread dieter
Joseph L. Casale jcas...@activenetwerx.com writes:
 ...
 After parsing the data for a user I am simply taking a value from the ldif 
 file and writing
 it back out to another which fails, the value parsed is:

 officestreetaddress:: T3R0by1NZcOfbWVyLVN0cmHDn2UgMQ==


   File C:\Python27\lib\site-packages\ldif.py, line 202, in unparse
 self._unparseChangeRecord(record)
   File C:\Python27\lib\site-packages\ldif.py, line 181, in 
 _unparseChangeRecord
 self._unparseAttrTypeandValue(mod_type,mod_val)
   File C:\Python27\lib\site-packages\ldif.py, line 142, in 
 _unparseAttrTypeandValue
 self._unfoldLDIFLine(':: 
 '.join([attr_type,base64.encodestring(attr_value).replace('\n','')]))
   File C:\Python27\lib\base64.py, line 315, in encodestring
 pieces.append(binascii.b2a_base64(chunk))
 UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 
 7: ordinal not in range(128)

 c:\python27\lib\base64.py(315)encodestring()
 - pieces.append(binascii.b2a_base64(chunk))

This looks like a coding bug: chunk seems to be a unicode string;
b2a_base64 expects an encoded string (str/bytes); as
a consequence, Python tries to convert the unicode to str by
encoding with its default enconding (ascii by default) - and
fails.

You could try to find out, why chunk is unicode (rather than str).
That will probably bring you to the real problem.

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


Re: Solving the problem of mutual recursion

2013-05-27 Thread Ian Kelly
On Sun, May 26, 2013 at 10:36 PM, Peter Brooks
peter.h.m.bro...@gmail.com wrote:
 This makes complete sense - any atomic action should be atomic, so two
 threads can't be doing it at the same time. They can be doing anything
 else though.

 If two threads create a new object at the same time, for example,
 there's potentially the problem that they'll get the same space, so
 the object will be owned by both. To prevent this, the new object call
 should be run in only one thread.

 If you have two objects running their methods on their own local
 variables, then there's no potential for conflict, so there's no need
 for them to be blocked.

That's not the way it works.  The CPython interpreter always runs with
the GIL held; the alternative would be to have individual mutex locks
on every Python object, which is expensive for performance due to the
reference counting mechanism.  Python functions can't release the GIL.
 C functions that are called from the interpreter *can* release the
GIL to allow concurrency, but are only permitted to do so as long as
they're not working with Python objects, e.g. waiting on I/O or
performing a long calculation on C data.

There are some more detailed slides on how the GIL works at:

http://www.dabeaz.com/python/UnderstandingGIL.pdf

Note that the description in Part 1 describes how the GIL worked prior
to Python 3.2.  The new GIL is described in Part 4, but the basic
underlying concept is the same.

 This is an interesting subject.. There's nothing wrong with the tool
 I'm using to report threads - 'Activity Monitor' is the standard
 process monitor. It counts cores as 'CPUs', which seems perfectly
 reasonable to me. As I said, other Unixes, such as HP-UX, do the same
 thing.

I have no problem with that.  It's also the default in Linux, where I
believe it is called IRIX mode (as opposed to Solaris mode, where
the difference is just a factor equal to the number of cores).  What I
was questioning was whether the actual number being reported was
correct.  If it's the standard tool for the OS, then it probably is.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python error codes and messages location

2013-05-27 Thread Cameron Simpson
On 27May2013 04:49, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote:
|  From: steve+comp.lang.pyt...@pearwood.info
|  On Mon, 27 May 2013 02:13:54 +0300, Carlos Nepomuceno wrote:
|  Where can I find all error codes and messages that Python throws (actual
|  codes and messages from exceptions raised by stdlib)?
| 
|  There is no list. It is subject to change from version to version,
|  including point releases.
[...]
|  Read the source code.
[...]
| 
| That's bad! I'd like to check all the IOError codes that may be
| raised by a function/method but the information isn't there.

No, you really don't.

There are particular, expected, errors you know what to do with
and can proceed in the face of.

And there will often be errors you _don't_ know what to do with.
With the latter, what is your program going to do? You often can't
proceed, so all you can do is log the error and cancel, cleaning
up as you back out. In that circumstance, how will knowing the name
of the error help? You've logged it, and hopefully the exception
message is sufficient.

| Take open() for example[1]. It only says it raises an IOError exception.
| 
| I've had to try open('','r') to discover that Errno 22 is the one IOError: 
[Errno 22] invalid mode ('r') or filename: ''

It is vague because that is an OS level error, and errno 22 is
EINVAL. For example, MacOSX says (in man 2 intro):

 22 EINVAL Invalid argument.  Some invalid argument was supplied. (For
 example, specifying an undefined signal to a signal or kill func‐
 tion).

It happens that above, the filename '' is invalid.

But so what? That call is _never_ going to work because the arguments
are invalid. So you response will be the same, programmatically,
as with many other errors: log and abort.

| Will I only be able to get all error codes reading the source code of open()?

Nope. Well, not directly.

Python open call's the OS' open. If that succeeds, Python does some
more housekeeping and hands you a file python object. But if the
OS open fails, Python reports the OS error.

From the Python source you will see that the OS open is called. So
you must then go to the OS docuemntation for further information.

| Is there a way to simulate the errors instead of actually causing
| them? I mean not raising an instance of IOError that I create (like
| raise IOError(666,'Hell happens')), but one with the actual
| contents 'args = (errno, strerr)' that open() would raise?
| 
| Something like:
| 
| f=open('filename','r')
| for x in range(25):
|     try:
|     f.raise_errno(x)
|     except IOError, e:
|     if   e.errno == 1:
|     treat_err1()
|     continue
|     elif e.errno == 2:
|     treat_err2()
|     continue

Well, maybe this (untested):

  for x in range(25):
      try:
      exc = OSError(os.strerror(x))
  exc.errno = x
  raise exc
      except IOError, e:
      if   e.errno == 1:
      treat_err1()
      continue
      elif e.errno == 2:
      treat_err2()
      continue

BTW, I recommend importing errno and using symbolic names. It makes things 
much more readable, and accomodates the situation where the symbols map to 
different numbers on different platforms. And have a catch-all. For example:

  import errno
  ...
  try:
f = open(filename, .)
  except OSError, e:
if e.errno == errno.EPERM:
  ... Operation not permitted ...
elif e.errno == errno.ENOENT:
  ... No such file or directory ...
else:
  # surprise!
  # log message, let the exception get out
  # callers can catch things in turn
  logging.error(open(%s) fails: %s % (filename, e))
  raise

|  I've already found the module 'errno' and got a dictionary
|  (errno.errorcode) and some system error messages
|  (os.strerror(errno.ENAMETOOLONG)) but there's more I couldn't find.
| 
|  These are the standard C operating system and file system error codes,
|  not Python exceptions.
| 
| Yes, the docs say it's from linux/include/errno.h.  
  

On Linux, yes. In general, on any UNIX system the command man 2
intro lists the errors that system calls like open may return. And
man 2 open should list the particular errors that open can return.
_On that platform_.

The platform variation is a major reason why you should not hope
to enumerate all the errors; the other reason is that you can't
treat every error individually in a fine grained fashion without
making your code hard to read and maintain: the core logic of the
program is hidden behind a forest of tiny little special cases.

Your code will be clearer if you handle the errors that are expected
and that permit the program to proceed sensible. Other errors should
elicit a log message of course, but if you can't proceed with the
task at hand you can almost certainly only abort and try to tidy
up while doing so.

Cheers,
-- 

Processes are like potatoes.- NCR 

Re: Short-circuit Logic

2013-05-27 Thread Cameron Simpson
On 27May2013 06:59, Vito De Tullio vito.detul...@gmail.com wrote:
| Cameron Simpson wrote:
|if s is not None and len(s)  0:
|  ... do something with the non-empty string `s` ...
|  
|  In this example, None is a sentinel value for no valid string and
|  calling len(s) would raise an exception because None doesn't have
|  a length.
| 
| obviously in this case an `if s: ...` is more than sufficient :P

:P

My fault for picking too similar a test.

Cheers,
-- 
Cameron Simpson c...@zip.com.au

Death is life's way of telling you you've been fired.   - R. Geis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Solving the problem of mutual recursion

2013-05-27 Thread Ian Kelly
On Sun, May 26, 2013 at 4:16 PM, Chris Angelico ros...@gmail.com wrote:
 On Mon, May 27, 2013 at 5:35 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 I'm pretty sure that CPython uses the GIL regardless of platform.  And
 yes you can have multiple OS-level threads, but because of the GIL
 only one will actually be running at a time.  Other possibilities
 include:

 6) It's spinning in a function that has released the GIL. Python
 threads can certainly execute concurrently; they just can't be
 manipulating Python objects. Most of the I/O functions will release
 the GIL before doing a potentially-blocking operation, and some
 CPU-heavy functions can do the same (I'm given to understand that
 numpy does this) - just depends on having a long job that involves no
 refcounted objects.

7) Since the program being tested does basically nothing except start
and exit threads, the extra 40% probably represents the overhead of
all that starting and stopping, which would be done outside the GIL.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to compare two json file line by line using python?

2013-05-27 Thread Avnesh Shakya
Thanks a lot, I got it.


On Mon, May 27, 2013 at 11:03 AM, Steven D'Aprano 
steve+comp.lang.pyt...@pearwood.info wrote:

 On Sun, 26 May 2013 21:32:40 -0700, Avnesh Shakya wrote:

  But I want to compare line by line and value by value. but i found that
  json data is unordered data, so how can i compare them without sorting
  it. please give me some idea about it. I am new for it. I want to check
  every value line by line.

 Why do you care about checking every value line by line? As you say
 yourself, JSON data is unordered, so line by line is the wrong way to
 compare it.


 The right way is to decode the JSON data, and then compare whether it
 gives you the result you expect:

 a = json.load(file-a)
 b = json.load(file-b)
 if a == b:
 print(file-a and file-b contain the same JSON data)

 If what you care about is the *data* stored in the JSON file, this is the
 correct way to check it.

 On the other hand, if you don't care about the data, but you want to
 detect changes to whitespace, blank lines, or other changes that make no
 difference to the JSON data, then there is no need to care that this is
 JSON data. Just treat it as text, and use the difflib library.

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


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

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


Re: Solving the problem of mutual recursion

2013-05-27 Thread Ian Kelly
On Mon, May 27, 2013 at 12:19 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 7) Since the program being tested does basically nothing except start
 and exit threads, the extra 40% probably represents the overhead of
 all that starting and stopping, which would be done outside the GIL.

To test this, I tried running the script in Python 2.7 in Linux with
the print statements removed and verified that it was using about 135%
of the CPU.  However, top also told me that only about 95% of that was
user processes; the other 40% was kernel usage.  The 40% doesn't seem
to be threading overhead though, because I tried adding large xrange
loops to slow down the thread creation process and it had no effect on
the stats.

Then I tried running the same program in Python 3.2, and I got the
more expected 100% CPU usage with minimal kernel time.  So I'm
thinking now that the extra 40% may actually be overhead induced by
the GIL.  If that's the case then wow, the old GIL really did suck.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help?? on functions

2013-05-27 Thread lokeshkoppaka
On Monday, May 27, 2013 11:18:34 AM UTC+5:30, Steven D'Aprano wrote:
 On Sun, 26 May 2013 21:48:34 -0700, lokeshkoppaka wrote:
 
 
 
  def shuffle(input, i, j):
 
  pass
 
  input = input[i:j+1] +input[0:i] + input[j+1:]
 
 
 
 pass does nothing. Take it out.
 
 
 
 
 
 
 
  def test_shuffle():
 
  input = [1, 2, 3, 4, 5, 6]
 
  shuffle(input, 1, 2)
 
  assert [2, 3, 1, 4, 5, 6] == input
 
  
 
  
 
  i had done the above code but the problem is i had manipulated the
 
  input in function shuffle(input, i, j) but once i get back to the
 
  test_shuffle() function again the variable input does not reflect the
 
  changes made in shuffle(input, i, j) why ,please can any one describe
 
  why . and help how to reflect that change to the variable input.
 
 
 
 The line of code:
 
 
 
 input = input[i:j+1] +input[0:i] + input[j+1:]
 
 
 
 
 
 takes the input list, makes three slices from that list, creates a new 
 
 list, and then reassigns the LOCAL variable input. This does not touch 
 
 the variable on the outside of the function.
 
 
 
 This will be more clear if you use different names:
 
 
 
 # Outside the function.
 
 mylist = [1, 2, 3, 4, 5, 6]
 
 shuffle(mylist, 1, 2)
 
 
 
 
 
 Inside the function shuffle, input is a local variable, and when you 
 
 reassign to it, the variable mylist on the outside is not changed. Try 
 
 this small function to see what I mean:
 
 
 
 def demo(input):
 
 print('local variable, before:', input)
 
 input = 100
 
 print('local variable, after:', input)
 
 print('non-local variable', mylist)
 
 
 
 
 
 mylist = [1, 2, 3, 4, 5, 6]
 
 demo(mylist)
 
 
 
 
 
 
 
 So, what can you do to fix this? You have two choices:
 
 
 
 
 
 1) You can return the shuffled list. Add this line to the end of your 
 
 shuffle function:
 
 
 
 return input
 
 
 
 
 
 and then inside the test function, do this:
 
 
 
 def test_shuffle():
 
 input = [1, 2, 3, 4, 5, 6]
 
 input = shuffle(input, 1, 2)
 
 assert [2, 3, 1, 4, 5, 6] == input
 
 
 
 
 
 2) You can modify the input list in place.
 
 
 
 In this case, instead of reassigning the local variable input with the 
 
 new list, you simply tell Python to stuff the new list inside the 
 
 original list. You do that with a slice:
 
 
 
 
 
 input[:] = input[i:j+1] + input[0:i] + input[j+1:]
 
 
 
 
 
 That's a small difference from what you wrote, just three characters [:], 
 
 but it makes a big difference in the effect. Instead of reassigning the 
 
 local variable to the new list, it takes the existing list, and replaces 
 
 each value inside it with the values taken from the new list. For example:
 
 
 
 
 
 py mylist = [100, 200, 300, 400, 500, 600]
 
 py mylist[3:5] = ['A', 'B', 'C']
 
 py mylist
 
 [100, 200, 300, 'A', 'B', 'C', 600]
 
 
 
 py mylist[1:] = [99, 98, 97]
 
 py mylist
 
 [100, 99, 98, 97]
 
 
 
 
 
 Any questions?
 
 
 
 
 
 -- 
 
 Steven

Steven 
wow, wonderful explanation ,i got it thanks a lot 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Solving the problem of mutual recursion

2013-05-27 Thread Chris Angelico
On Mon, May 27, 2013 at 4:07 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Sun, May 26, 2013 at 10:36 PM, Peter Brooks
 peter.h.m.bro...@gmail.com wrote:
 This makes complete sense - any atomic action should be atomic, so two
 threads can't be doing it at the same time. They can be doing anything
 else though.

 If two threads create a new object at the same time, for example,
 there's potentially the problem that they'll get the same space, so
 the object will be owned by both. To prevent this, the new object call
 should be run in only one thread.

 If you have two objects running their methods on their own local
 variables, then there's no potential for conflict, so there's no need
 for them to be blocked.

 That's not the way it works. [snip details]

You're actually both saying the same thing, except that Peter went for
finer granularity than Ian and CPython did. CPython figures that, with
a refcounted heap, there's not a lot of point having separate mutex
locks for different operations. Other language interpreters have made
other choices. But Peter's analysis is still correct; it's just that
guarding it is simplified down to a binary state: either you have the
GIL, or you don't.

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


Re: Python error codes and messages location

2013-05-27 Thread Chris Angelico
On Mon, May 27, 2013 at 4:11 PM, Cameron Simpson c...@zip.com.au wrote:
 On 27May2013 04:49, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote:
 | That's bad! I'd like to check all the IOError codes that may be
 | raised by a function/method but the information isn't there.

 No, you really don't.

Heh. I concur. Opening a file can generate roughly forty-two million
different errors. Here's a smattering that you might not be expecting:

* The path points somewhere that's not currently mounted
* The path represents a device that is not properly working
* It's over a network and the server at the far end is down
* It's over a network and the server sends back maliciously crafted data
* It's over a network and the server sends back an incorrect error code
* You tried to open something that doesn't exist, and your disk quota is used up
* The system has run out of handles
* You're trying to create something in the root directory of a FAT
volume that already has too many root directory entries

And plenty more besides. Those are just a few that I could come up
with off the top of my head.

Just catch whatever makes sense (IOError maybe), and don't sweat the details.

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


Re: Ldap module and base64 oncoding

2013-05-27 Thread Michael Ströder
Joseph L. Casale wrote:
 After parsing the data for a user I am simply taking a value from the ldif 
 file and writing
 it back out to another which fails, the value parsed is:
 
 officestreetaddress:: T3R0by1NZcOfbWVyLVN0cmHDn2UgMQ==
 
 
   File C:\Python27\lib\site-packages\ldif.py, line 202, in unparse
 self._unparseChangeRecord(record)
   File C:\Python27\lib\site-packages\ldif.py, line 181, in 
 _unparseChangeRecord
 self._unparseAttrTypeandValue(mod_type,mod_val)
   File C:\Python27\lib\site-packages\ldif.py, line 142, in 
 _unparseAttrTypeandValue
 self._unfoldLDIFLine(':: 
 '.join([attr_type,base64.encodestring(attr_value).replace('\n','')]))
   File C:\Python27\lib\base64.py, line 315, in encodestring
 pieces.append(binascii.b2a_base64(chunk))
 UnicodeEncodeError: 'ascii' codec can't encode character u'\xdf' in position 
 7: ordinal not in range(128)

Note that all modules in python-ldap up to 2.4.10 including module 'ldif'
expect raw byte strings to be passed as arguments. It seems to me you're
passing a Unicode object in the entry dictionary which will fail in case an
attribute value contains NON-ASCII chars.

python-ldap expects raw strings since it's not schema-aware and therefore does
not have any knowledge about the LDAP syntax used for a particular attribute
type. So automagically convert Unicode strings will likely fail in many cases.
= The calling application has to deal with it.

 I now have the exact the value I started with. Ensuring where I ever handle 
 the original
 values that I return utf-8 decoded objects for use in a modlist to later 
 write and Sub
 classing LDIFWriter and overriding _unparseAttrTypeandValue to do the 
 encoding has
 eliminated all the errors.

Don't muck with overriding  _unparseAttrTypeandValue(). Simply pass the
properly encoded data into ldif module.

Ciao, Michael.

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


Re: help?? on functions

2013-05-27 Thread John Ladasky
Steven gave you a lot of good advice.  Let me add just one remark.

Python already has a builtin function called input.  If you define a variable 
with the same name as a builtin and then you try to use that builtin, you will 
be in for a (usually unpleasant) surprise.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Piping processes works with 'shell = True' but not otherwise.

2013-05-27 Thread Chris Angelico
On Mon, May 27, 2013 at 9:58 AM, Luca Cerone luca.cer...@gmail.com wrote:
 Could you provide the *actual* commands you're using, rather than the 
 generic program1 and program2 placeholders? It's *very* common for 
 people to get the tokenization of a command line wrong (see the Note box in 
 http://docs.python.org/2/library/subprocess.html#subprocess.Popen for some 
 relevant advice).

 Hi Chris, first of all thanks for the help. Unfortunately I can't provide the 
 actual commands because are tools that are not publicly available.
 I think I get the tokenization right, though.. the problem is not that the 
 programs don't run.. it is just that sometimes I get that error..

Will it violate privacy / NDA to post the command line? Even if we
can't actually replicate your system, we may be able to see something
from the commands given.

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


Re: This mail never gets delivered. Any ideas why?

2013-05-27 Thread Νίκος Γκρ33κ
Please, do you see an error in this?
As i said the 2nd solution doesnt provide an error but also doesn't get the 
mail send too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Problems with python and pyQT

2013-05-27 Thread silusilusilu
Hi, 
i'm new with python: so excuse me for my questions
i have this code:

def updateLog(self, text):
self.ui.logTextEdit.moveCursor(QTextCursor.End)
self.ui.logTextEdit.insertHtml(font color=\Black\+text)
self.ui.logTextEdit.moveCursor(QTextCursor.End)

logTextEdit is a QTextEdit object.With this code,i can display only ascii 
characters: how can i diplay text as hex and binary values?
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


How to create new python file with increament number, if doesn't exist?

2013-05-27 Thread Avnesh Shakya
hi,
   I want to create a new python file like 'data0.0.5', but if it is already 
exist then it should create 'data0.0.6', if it's also exist then next like 
'data0.0.7'. I have done, but with range, please give me suggestion so that I 
can do it with specifying range.
I was trying this way and it's working also..

 i = 0
for i in range(100):
try:
with open('Data%d.%d.%d.json'%(0,0,i,)): pass
continue
except IOError:
edxCorrectDataFile = file('Data%d.%d.%d.json'%(0,0,i,), 'a+')
break

But here I have defined range 100, Is it possible without range it create many 
required files?

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


Re: How to create new python file with increament number, if doesn't exist?

2013-05-27 Thread Denis McMahon
On Mon, 27 May 2013 02:27:59 -0700, Avnesh Shakya wrote:

 I want to create a new python file like 'data0.0.5', but if it is
 already exist then it should create 'data0.0.6', if it's also exist
 then next like 'data0.0.7'. I have done, but with range, please give
 me suggestion so that I can do it with specifying range.

Try and put your description into the sequence of instructions you want 
the computer follow.

For this problem, my sequence of instructions would be:

1) Find the highest numbered existing file that matches the filename 
data0.0.[number]

2) Create a new file that is one number higher.

Now the solution is easy. Find the list of filenames in the directory 
that match a suitable regular expression, take the numeric value of a 
substring of the filename for each file and find the highest, add one to 
it, then create the new file name.

Something like the following (untested) with the relevant imports etc:

nfn=data0.0.+str(max([int(f[8:])for f in os.listdir(p)if re.match
('^data0.0.[0-9]+$',f)])+1)

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


Re: how to compare two json file line by line using python?

2013-05-27 Thread Denis McMahon
On Sun, 26 May 2013 21:32:40 -0700, Avnesh Shakya wrote:

how to compare two json file line by line using python? Actually I am
doing it in this way..

Oh what a lot of homework you have today.

Did you ever stop to think what the easiest way to compare two json 
datasets is?

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


Re: How to create new python file with increament number, if doesn't exist?

2013-05-27 Thread Avnesh Shakya
Thanks


On Mon, May 27, 2013 at 4:19 PM, Denis McMahon denismfmcma...@gmail.comwrote:

 On Mon, 27 May 2013 02:27:59 -0700, Avnesh Shakya wrote:

  I want to create a new python file like 'data0.0.5', but if it is
  already exist then it should create 'data0.0.6', if it's also exist
  then next like 'data0.0.7'. I have done, but with range, please give
  me suggestion so that I can do it with specifying range.

 Try and put your description into the sequence of instructions you want
 the computer follow.

 For this problem, my sequence of instructions would be:

 1) Find the highest numbered existing file that matches the filename
 data0.0.[number]

 2) Create a new file that is one number higher.

 Now the solution is easy. Find the list of filenames in the directory
 that match a suitable regular expression, take the numeric value of a
 substring of the filename for each file and find the highest, add one to
 it, then create the new file name.

 Something like the following (untested) with the relevant imports etc:

 nfn=data0.0.+str(max([int(f[8:])for f in os.listdir(p)if re.match
 ('^data0.0.[0-9]+$',f)])+1)

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

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


Re: How to create new python file with increament number, if doesn't exist?

2013-05-27 Thread Jens Thoms Toerring
Avnesh Shakya avnesh.n...@gmail.com wrote:
I want to create a new python file like 'data0.0.5', but if it is already
 exist then it should create 'data0.0.6', if it's also exist then next like
 'data0.0.7'. I have done, but with range, please give me suggestion so that
 I can do it with specifying range.
 I was trying this way and it's working also..

 i = 0
 for i in range(100):
 try:
 with open('Data%d.%d.%d.json'%(0,0,i,)): pass
 continue
 except IOError:
 edxCorrectDataFile = file('Data%d.%d.%d.json'%(0,0,i,), 'a+')
 break

 But here I have defined range 100, Is it possible without range it create
 many required files?

What about something as simple as this?

  i = 0
  while os.path.exists( 'Data{0}.{1}.{2}.json'.format( 0, 0, i ) ) :
  i += 1
  f = open( 'Data{0}.{1}.{2}.json'.format( 0, 0, i ), 'w' )

For your code you'ld make it e.g.

  i = 0
  try:
  while True :
  with open('Data%d.%d.%d.json'%(0,0,i)):
  i += 1
  except IOError:
  edxCorrectDataFile = file('Data%d.%d.%d.json'%(0,0,i), 'a+')

Note that I don't see how all this trying to open a file and
catching an exeception if it doesn't exist is any better
than simply using os.path.exists(). You may have read some-
where that it avoids a race condition and would thus be more
secure. That's not the case here, an attacker still could
create e.g. a symbolic link with the name of the file you're
going to open between the time the exception is thrown and your
program getting around to open the file you expect not to exist,
so nothing is gained by using this somewhat convoluted method.
What would be needed for avoiding a race condition is an addi-
tional flag to be passed to open() like the for example the
O_EXCL flag that can be passed to Unix' open() system function.
But that isn't supported by Pythons open() function which
rather likeky is based on C's fopen() function). The best
advice to avoid such problems is probably not to open files
with a predictable name (or better to use one of the methods
to create files with names guaranteed to be unique by the
system) in directories to which other users than you also
have write permission.
Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Piping processes works with 'shell = True' but not otherwise.

2013-05-27 Thread Luca Cerone
 
 
 Will it violate privacy / NDA to post the command line? Even if we
 
 can't actually replicate your system, we may be able to see something
 
 from the commands given.
 
 

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


Re: Python error codes and messages location

2013-05-27 Thread Mark Lawrence

On 27/05/2013 07:11, Cameron Simpson wrote:


BTW, I recommend importing errno and using symbolic names. It makes things 
much more readable, and accomodates the situation where the symbols map to different 
numbers on different platforms. And have a catch-all. For example:

Cheers,



This should make life easier for us 
http://docs.python.org/3/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: This mail never gets delivered. Any ideas why?

2013-05-27 Thread Mark Lawrence

On 27/05/2013 10:15, Νίκος Γκρ33κ wrote:

Please, do you see an error in this?
As i said the 2nd solution doesnt provide an error but also doesn't get the 
mail send too.



At least you're improving.  Yesterday you were chasing after two hours, 
it's now up to four hours 15 minutes.  Keep doubling the time like this 
and you'll soon be up to the 24 hours that's considered polite.  As 
previously stated the time can be shortened substantially by getting 
your cheque book out.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Scary Pranks

2013-05-27 Thread MoneyMaker
http://horrorhorrorhorror.webs.com/scary-pranks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python error codes and messages location

2013-05-27 Thread Fábio Santos
On 27 May 2013 12:41, Mark Lawrence breamore...@yahoo.co.uk wrote:
 This should make life easier for us
http://docs.python.org/3/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy

Speaking of PEPs and exceptions. When do we get localized exceptions?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems with python and pyQT

2013-05-27 Thread Chris “Kwpolska” Warrick
On Mon, May 27, 2013 at 11:26 AM,  silusilus...@gmail.com wrote:
 Hi,
 i'm new with python: so excuse me for my questions
 i have this code:

 def updateLog(self, text):
 self.ui.logTextEdit.moveCursor(QTextCursor.End)
 self.ui.logTextEdit.insertHtml(font color=\Black\+text)
 self.ui.logTextEdit.moveCursor(QTextCursor.End)

 logTextEdit is a QTextEdit object.With this code,i can display only ascii 
 characters: how can i diplay text as hex and binary values?
 Thanks
 --
 http://mail.python.org/mailman/listinfo/python-list

You would need to convert them to strings first.  You may want bin()
and hex() for that.  And if you want to convert 'q' to 0x71,
hex(ord(q)).  And if you want to turn 'hello' into 0x68656c6c6f, you
would need to iterate over 'hello' and run the above function over
every letter.

Also, you are able to display Unicode characters, too.

--
Kwpolska http://kwpolska.tk | GPG KEY: 5EAAEA16
stop html mail| always bottom-post
http://asciiribbon.org| http://caliburn.nl/topposting.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python error codes and messages location

2013-05-27 Thread Steven D'Aprano
On Mon, 27 May 2013 13:46:50 +0100, Fábio Santos wrote:

 Speaking of PEPs and exceptions. When do we get localized exceptions? 


We're waiting for you to volunteer. When can you start?


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


Re: Python error codes and messages location

2013-05-27 Thread Fábio Santos
On Mon, May 27, 2013 at 2:11 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Mon, 27 May 2013 13:46:50 +0100, Fábio Santos wrote:

 Speaking of PEPs and exceptions. When do we get localized exceptions?


 We're waiting for you to volunteer. When can you start?

I'd love to work on that but my C is too shabby to say the least.

--
Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encodign issue in Python 3.3.1 (once again)

2013-05-27 Thread Νίκος Γκρ33κ
I cant solve this plz help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encodign issue in Python 3.3.1 (once again)

2013-05-27 Thread Michael Torrie
On 05/26/2013 11:06 PM, Νίκος Γκρ33κ wrote:
 But iu have it set up for 'utf-8' as seen in this statement.
 
 con = pymysql.connect( db = 'metrites', host = 'localhost', user = 
 'me', passwd = 'somepass', charset='utf-8', init_command='SET NAMES UTF8' ) 

That might not help... see below.

 
 Yoiu mean i shoudl chnag eit to greek isoo= (iso-8859-7)
 but then i store english names and greek names as well, so it has to be a 
 utf-8.

Right.  UTF-8 is the encoding you want.

I think your problem is that when the MySQL database was created, it was
not created using the UTF-8 mode, but rather latin-1 (despite your
init_command which has nothing to do with database creation).  You'll
want to recreate the database and make double sure you've selected the
right character set and collation:

http://dev.mysql.com/doc/refman/5.0/en/charset-applications.html

At least that should be your first step in debugging this problem.

If the database is indeed utf-8, then you can move on to debugging why
the python code is choosing latin-1 to encode your query string.

That's my two-cents for today.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to get an integer from a sequence of bytes

2013-05-27 Thread Mok-Kong Shen

From an int one can use to_bytes to get its individual bytes,
but how can one reconstruct the int from the sequence of bytes?

Thanks in advance.

M. K. Shen
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encodign issue in Python 3.3.1 (once again)

2013-05-27 Thread Mark Lawrence

On 27/05/2013 15:16, Νίκος Γκρ33κ wrote:

I cant solve this plz help!



Sure, all you need do is get your cheque book out.  Also have you ever 
heard the expression patience is a virtue?


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: How to get an integer from a sequence of bytes

2013-05-27 Thread Steven D'Aprano
On Mon, 27 May 2013 16:45:05 +0200, Mok-Kong Shen wrote:

 From an int one can use to_bytes to get its individual bytes, but how
 can one reconstruct the int from the sequence of bytes?

Here's one way:

py n = 11999102937234
py m = 0
py for b in n.to_bytes(6, 'big'):
... m = 256*m + b
...
py m == n
True


-- 
Steven

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


Re: Future standard GUI library

2013-05-27 Thread Wolfgang Keller
 Your back end exposes services and business logic, and your front end
 can be in HTMLv5 and Javascript, or QtQuick, PyGTK, or Visual
 Studio.  If you do need a native interface, it's a heck of a lot
 easier to rewrite just the frontend then the entire stack.

Any decent database CRUD framework will allow to implement the
application model as behaviour complete domain objects, with a
persistence layer totally independent from the GUI layer. In many
Python RAD frameworks, this is done using SQLalchemy.

 Who cares how the RPC is done;

As an end-user I do care for how much an application makes we watch the
cursor animation.

 that's an implementation detail.  HTTP does happen to work well
 though.  Why do you say it is not suitable?

Because from personal experience I know too well that it does definitely
not work well though. 

 suppose I now want the app natively on my phone (because that's all
 the rage).  It's an iPhone.  Oh.  Apple doesn't support Python.
 Okay, rewrite the works, including business logic, in Objective C.
 Now I want it on my android phone. 

Those are gadgets, not work tools.

Sincerely,

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


Re: How to get an integer from a sequence of bytes

2013-05-27 Thread Ned Batchelder

On 5/27/2013 10:45 AM, Mok-Kong Shen wrote:

From an int one can use to_bytes to get its individual bytes,
but how can one reconstruct the int from the sequence of bytes?



The next thing in the docs after int.to_bytes is int.from_bytes: 
http://docs.python.org/3.3/library/stdtypes.html#int.from_bytes


--Ned.


Thanks in advance.

M. K. Shen


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


Re: Future standard GUI library

2013-05-27 Thread Wolfgang Keller
 HTTP handles that just fine, with your choice of XML, 

And XML is definitely not suitable as a marshalling format for a RPC
protocol.

XML-over-HTTP is a true cerebral flatulance of some hopelessly clueless
moron.

Sincerely,

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


Re: Encodign issue in Python 3.3.1 (once again)

2013-05-27 Thread Νίκος Γκρ33κ
Τη Δευτέρα, 27 Μαΐου 2013 5:45:25 μ.μ. UTC+3, ο χρήστης Mark Lawrence έγραψε:

 Sure, all you need do is get your cheque book out.  Also have you ever 
 heard the expression patience is a virtue?

Well, if i'am gonna pay someone and i will at some point because i want my 
script to be also re-written using a web framework(Django) it will certainly be 
someone that can actually provide a so;lution instead of aksing for cheque 
books.

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


Re: Encodign issue in Python 3.3.1 (once again)

2013-05-27 Thread Chris Angelico
On Tue, May 28, 2013 at 1:37 AM, Νίκος Γκρ33κ nikos.gr...@gmail.com wrote:
 Τη Δευτέρα, 27 Μαΐου 2013 5:45:25 μ.μ. UTC+3, ο χρήστης Mark Lawrence έγραψε:

 Sure, all you need do is get your cheque book out.  Also have you ever
 heard the expression patience is a virtue?

 Well, if i'am gonna pay someone and i will at some point because i want my 
 script to be also re-written using a web framework(Django) it will certainly 
 be someone that can actually provide a so;lution instead of aksing for cheque 
 books.

So you want to pay someone who won't ask for money?

It may be sordid, but you're going to have to discuss money at some
point if you're serious about paying someone.

Oh, and you may want to hire a typist, too. At the moment, your posts
make you appear not to care about the job.

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


RE: Python error codes and messages location

2013-05-27 Thread Carlos Nepomuceno
Thanks so much guys!

I'm not planning to prepare for every possible situation, but I certainly am 
responsible to handle most common errors. So it's really important to know what 
a function/method returns when called.

Exception handling may take lots of code, but I'm used to it. It's much better 
to have a graceful shutdown than a data/time loss. ;)

I think PEP 3151 is a step ahead! That's almost exactly what I was looking for. 
Why did it take so long to have that implemented?   
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encodign issue in Python 3.3.1 (once again)

2013-05-27 Thread Νίκος Γκρ33κ
Τη Δευτέρα, 27 Μαΐου 2013 6:52:32 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε:

 So you want to pay someone who won't ask for money?
 It may be sordid, but you're going to have to discuss money at some
 point if you're serious about paying someone.
 Oh, and you may want to hire a typist, too. At the moment, your posts 
 make you appear not to care about the job.

I always make typos when iam typing fast.
And yes at some point i will pay a person from this groups to alter my scripts 
to utilize web frameworks.
To answer your question yes, i will be paying a person from this group that 
have been providing me solutions to previous questions without laughing at my 
expense and without requiring money frome to do so.
I have 2-3 people in mind.
I have managed to turn ALL my python 2.6 scripts to python 3.3.1 except this 
last problem i have to deal with.

http://superhost.gr/?page=pelatologio.py works partiall but only displays info 
when i click on person names in English, not with Greek names.

If someone want to give me a hand with this, please do.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-27 Thread Michael Torrie
On 05/27/2013 09:31 AM, Wolfgang Keller wrote:
 HTTP handles that just fine, with your choice of XML, 
 
 And XML is definitely not suitable as a marshalling format for a RPC
 protocol.
 
 XML-over-HTTP is a true cerebral flatulance of some hopelessly clueless
 moron.

Hmm.  Well I think there are a lot of very smart developers that are
using xml to marshal rpc and it's working fine.  So either they know
something you don't, or maybe they are just busy making code that
functions and functions pretty well, instead of making inflammatory
statements on USENET.  Sure XML is not very efficient or compact, but it
does handle unicode intrinsically through standard encodings, and a
plethora of parsers makes it a decent choice.  It's like what they say
about the book: for though it has many omissions and contains much that
is apocryphal, or at least wildly inaccurate, it scores over the older,
more pedestrian work in two important respects.
First, it is slightly cheaper; and second, it has the words Don't Panic
inscribed in large friendly letters on its cover.

I've used LBER-encoded wire protocol before, and it was fine, but hard
to debug on the wire, and didn't haven anything in it to handle unicode
except base64-encoding utf8 byte streams.

That said, all this reminds me of a good saying, XML is like violence;
if it doesn't solve your problem you're not using enough of it.
Fortunately none of this really matters.  Who cares what is used to
marshall RPC over the wire? As a developer I certainly don't care.  I'll
use whatever is convenient and well supported.  One reason I do like
xmlrpc, though, because it's pretty much available to all web-based back
ends for free (or at little cost) and you don't need to set up a special
server process to handle it, or deal with odd port numbers that might be
blocked, doing ssl yourself, etc.  Having HTTP do the transport frees me
from having to worry about all that, since in the case of a web app I am
already using a web server.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-27 Thread Michael Torrie
On 05/27/2013 09:22 AM, Wolfgang Keller wrote:
 suppose I now want the app natively on my phone (because that's all
 the rage).  It's an iPhone.  Oh.  Apple doesn't support Python.
 Okay, rewrite the works, including business logic, in Objective C.
 Now I want it on my android phone. 
 
 Those are gadgets, not work tools.

As a professional programmer I'm afraid you're going to soon find
yourself out of work if you really see things that way.  I honestly used
to feel that way about graphical user interfaces.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python error codes and messages location

2013-05-27 Thread Mark Lawrence

On 27/05/2013 17:54, Carlos Nepomuceno wrote:


I think PEP 3151 is a step ahead! That's almost exactly what I was looking for. 
Why did it take so long to have that implemented?   




Lack of volunteers.

--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Python error codes and messages location

2013-05-27 Thread Terry Jan Reedy

On 5/27/2013 12:54 PM, Carlos Nepomuceno wrote:


I think PEP 3151 is a step ahead! That's almost exactly what I was looking for. 
Why did it take so long to have that implemented?   



Since this PEP involved changing existing features, rather than adding 
something mew, it probably took moe time and discussion to get consensus 
on details of the change.


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


Re: Python error codes and messages location

2013-05-27 Thread Vito De Tullio
Fábio Santos wrote:

 This should make life easier for us
 http://docs.python.org/3/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy
 
 Speaking of PEPs and exceptions. When do we get localized exceptions?

What do you mean by localized exceptions?

Please, tell me it's *NOT* a proposal to send the exception message in the 
locale language!

-- 
By ZeD

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


Re: Python error codes and messages location

2013-05-27 Thread Fábio Santos
On 27 May 2013 19:23, Vito De Tullio vito.detul...@gmail.com wrote:

 Fábio Santos wrote:

  This should make life easier for us
 
http://docs.python.org/3/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy
 
  Speaking of PEPs and exceptions. When do we get localized exceptions?

 What do you mean by localized exceptions?

 Please, tell me it's *NOT* a proposal to send the exception message in the
 locale language!

 --
 By ZeD

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

It is. I think I read it mentioned in python-dev or this list.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: serialize a class to XML and back

2013-05-27 Thread Irmen de Jong
On 27-5-2013 2:39, Roy Smith wrote:
 In article 51a28f42$0$15870$e4fe5...@news.xs4all.nl,
  Irmen de Jong irmen.nos...@xs4all.nl wrote:
 
 On 26-5-2013 22:48, Roy Smith wrote:

 The advantage of pickle over json is that pickle can serialize many 
 types of objects that json can't.  The other side of the coin is that 
 pickle is python-specific, so if you think you'll ever need to read your 
 data from other languages, pickle is right out.

 That is not entirely true :)  I've written a pickle implementation for Java 
 and .NET
 that is almost feature complete; it is part of 
 http://pythonhosted.org/Pyro4/pyrolite.html
 
 Very cool
 
 Still, pickle may not be the best choice here.
 
 Perhaps not, but lots of points for the awesomeness factor.
 

Thanks for the praise :)

There's another interesting thing perhaps to also mention about Pyrolite. Its 
Pickle
implementation obviously maps built in types to their counterparts in 
Java/.NET, but it
is also capable of unpickling custom classes. It defaults to outputting a simple
hashtable with the class's properties in it, but you can also provide a custom
deserializer to recreate a custom object (it already does this automatically 
for a few
complex types such as DateTime, BigDecimal, and a bunch of Pyro specific types).

As the unpicklers are not executing any Java or .NET code dynamically they are 
not
susceptible to the security issue that Python's pickle has. Still: tread with 
care.
(Especially if you use the lib to pickle stuff and unpickle it on the Python 
side).

Also, the one missing feature is memo-ing when pickling so that you can pickle 
recursive
object graphs. It now throws a stack overflow exception instead.


Irmen


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


SQLObject 1.3.3 and 1.4.1

2013-05-27 Thread Oleg Broytman
Hello!

I'm pleased to announce bugfix releases 1.3.3 and 1.4.1.


What's new in SQLObject
===

* Fixed bugs in pickling and unpickling (remove/restore a weak proxy to self,
  fixed cache handling).

* Added an example of using SQLObject with web.py to the links page.

Contributors for this release are Andrew Trusty and Rhubarb Sin.

For a more complete list, please see the news:
http://sqlobject.org/News.html


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
https://pypi.python.org/pypi/SQLObject/1.3.3
https://pypi.python.org/pypi/SQLObject/1.4.1

News and changes:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 64-bit Python for Solaris

2013-05-27 Thread Matchek
Crickets

2013/5/21 Maciej (Matchek) Bliziński mac...@opencsw.org:
 the ${prefix}/lib/pythonX.Y/_sysconfigdata.py file contains
 system-specific information

...and is installed in an architecture-independent directory by the
Python installer. This looks broken to me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short-circuit Logic

2013-05-27 Thread Ahmed Abdulshafy
On Sunday, May 26, 2013 1:11:56 PM UTC+2, Ahmed Abdulshafy wrote:
 Hi,
 
 I'm having a hard time wrapping my head around short-circuit logic that's 
 used by Python, coming from a C/C++ background; so I don't understand why the 
 following condition is written this way!
 
 
 
  if not allow_zero and abs(x)  sys.float_info.epsilon:
 
 print(zero is not allowed)
 
 
 
 The purpose of this snippet is to print the given line when allow_zero is 
 False and x is 0.

Thank you guys! you gave me valuable insights! But regarding my original post, 
I don't know why for the past two days I was looking at the code *only* this 
way
 if ( not allow_zero and abs(x) )  sys.float_info.epsilon:

I feel so stupid now :-/, may be it's the new syntax confusing me :)! Thanks 
again guys.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short-circuit Logic

2013-05-27 Thread Ahmed Abdulshafy
On Sunday, May 26, 2013 2:13:47 PM UTC+2, Steven D'Aprano wrote:
 On Sun, 26 May 2013 04:11:56 -0700, Ahmed Abdulshafy wrote:
 
 
 
  Hi,
 
  I'm having a hard time wrapping my head around short-circuit logic
 
  that's used by Python, coming from a C/C++ background; so I don't
 
  understand why the following condition is written this way!
 
  
 
   if not allow_zero and abs(x)  sys.float_info.epsilon:
 
  print(zero is not allowed)
 
 
 
 Follow the logic.
 
 
 
 If allow_zero is a true value, then not allow_zero is False, and the 
 
 and clause cannot evaluate to true. (False and X is always False.) So 
 
 print is not called.
 
 
 
 If allow_zero is a false value, then not allow_zero is True, and the 
 
 and clause depends on the second argument. (True and X is always X.) So
 
 abs(x)  sys.float_info.epsilon is tested, and if that is True, print is 
 
 called.
 
 
 
 By the way, I don't think much of this logic. Values smaller than epsilon 
 
 are not necessarily zero:
 
 
 
 py import sys
 
 py epsilon = sys.float_info.epsilon
 
 py x = epsilon/1
 
 py x == 0
 
 False
 
 py x * 3 == 0
 
 False
 
 py x + epsilon == 0
 
 False
 
 py x + epsilon == epsilon
 
 False
 
 
 
 The above logic throws away many perfectly good numbers and treats them 
 
 as zero even though they aren't.
 
 
 
 
 
  The purpose of this snippet is to print the given line when allow_zero
 
  is False and x is 0.
 
 
 
 Then the snippet utterly fails at that, since it prints the line for many 
 
 values of x which can be distinguished from zero. The way to test whether 
 
 x equals zero is:
 
 
 
 x == 0
 
 
 
 What the above actually tests for is whether x is so small that (1.0+x) 
 
 cannot be distinguished from 1.0, which is not the same thing. It is also 
 
 quite arbitrary. Why 1.0? Why not (0.0001+x)? Or (0.0001+x)? Or 
 
 (1.0+x)?
 
 
 
 
 
 
 
 -- 
 
 Steven

That may be true for integers, but for floats, testing for equality is not 
always precise
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encodign issue in Python 3.3.1 (once again)

2013-05-27 Thread Νίκος Γκρ33κ
I have checked the database through phpMyAdmin and it is indeed UTF-8.

I have no idea why python 3.3.1 chooses to work with latin-iso only
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short-circuit Logic

2013-05-27 Thread Nobody
On Sun, 26 May 2013 04:11:56 -0700, Ahmed Abdulshafy wrote:

 I'm having a hard time wrapping my head around short-circuit logic that's
 used by Python, coming from a C/C++ background; so I don't understand why
 the following condition is written this way!
 
  if not allow_zero and abs(x)  sys.float_info.epsilon:
 print(zero is not allowed)
 
 The purpose of this snippet is to print the given line when allow_zero is
 False and x is 0.

I don't understand your confusion. The above is directly equivalent to the
following C code:

if (!allow_zero  fabs(x)  DBL_EPSILON)
printf(zero is not allowed\n);

In either case, the use of short-circuit evaluation isn't necessary here;
it would work just as well with a strict[1] and operator.

Short-circuit evaluation is useful if the second argument is expensive to
compute, or (more significantly) if the second argument should not be
evaluated if the first argument is false; e.g. if x is a pointer then:

if (x  *x) ...

relies upon short-circuit evaluation to avoid dereferencing a null pointer.

On an unrelated note: the use of the epsilon value here is
almost certainly wrong. If the intention is to determine if the result of
a calculation is zero to within the limits of floating-point accuracy,
then it should use a value which is proportional to the values used in
the calculation.

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


Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Bryan Britten
Hey, everyone! 

I'm very new to Python and have only been using it for a couple of days, but 
have some experience in programming (albeit mostly statistical programming in 
SAS or R) so I'm hoping someone can answer this question in a technical way, 
but without using an abundant amount of jargon.

The issue I'm having is that I'm trying to pull information from a website to 
practice Python with, but I'm having trouble getting the data in a timely 
fashion. If I use the following code:

code
import json
import urllib

urlStr = https://stream.twitter.com/1/statuses/sample.json;

twtrDict = [json.loads(line) for line in urllib.urlopen(urlStr)]
/code

I get a memory issue. I'm running 32-bit Python 2.7 with 4 gigs of RAM if that 
helps at all.

If I use the following code:

code
import urllib

urlStr = https://stream.twitter.com/1/statuses/sample.json;

fileHandle = urllib.urlopen(urlStr)

twtrText = fileHandle.readlines()
/code

It takes hours (upwards of 6 or 7, if not more) to finish computing the last 
command.

With that being said, my question is whether there is a more efficient manner 
to do this. I'm worried that if it's taking this long to process the 
.readlines() command, trying to work with the data is going to be a 
computational nightmare.

Thanks in advance for any insights or advice!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Roy Smith
In article 10be5c62-4c58-4b4f-b00a-82d85ee4e...@googlegroups.com,
 Bryan Britten britten.br...@gmail.com wrote:

 If I use the following code:
 
 code
 import urllib
 
 urlStr = https://stream.twitter.com/1/statuses/sample.json;
 
 fileHandle = urllib.urlopen(urlStr)
 
 twtrText = fileHandle.readlines()
 /code
 
 It takes hours (upwards of 6 or 7, if not more) to finish computing the last 
 command.

I'm not surprised!  readlines() reads in the ENTIRE file in one gulp.  
That a lot of tweets!

 With that being said, my question is whether there is a more efficient manner 
 to do this.

In general, when reading a large file, you want to iterate over lines of 
the file and process each one.  Something like:

for line in urllib.urlopen(urlStr):
   twtrDict = json.loads(line)

You still need to download and process all the data, but at least you 
don't need to store it in memory all at once.  There is an assumption 
here that there's exactly one json object per line.  If that's not the 
case, things might get a little more complicated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Minor consistency question in io.IOBase

2013-05-27 Thread dwight . guth
Hi, so, I don't necessarily know if this is the right place to ask this 
question since it's kindof a rather technical one which gets into details of 
the python interpreter itself, but I thought I'd start here and if nobody knew 
the answer, they could let me know if it makes sense to ask on python-dev.

I am wondering why it is that the default implementations of certain of the 
mixin methods on IOBase seem to behave somewhat inconsistently. Specifically, 
the behavior of precisely when in the pipeline a method checks to see whether 
the object is already closed seems to be inconsistent.

In the following methods:

IOBase.__next__
IOBase.readline
IOBase.tell

In each case, these methods never check to see whether the file is closed. 
__next__ immediately calls readline(), readline(limit) calls read(1) at most 
limit times, and tell calls seek(0, 1). It is relying on the underlying method 
to raise a ValueError if the file is already closed. Otherwise, __next__ and 
readline will raise AttributeErrors on unreadable files, and tell will raise an 
UnsupportedOperation on unseekable files. A side effect of this is that 
readline(0) on a closed file will succeed.

In the following methods, however:

IOBase.writelines
IOBase.readlines

In each case, the methods will check to determine whether the file has been 
closed before ever calling their underlying method. Thus, calling 
writelines([]) will raise a ValueError on a closed file, though it never calls 
write. Similarly, readlines() will raise a ValueError on a closed file before 
ever calling readline() even once.

Can someone explain to me if there's some kind of consistent logic that 
explains the differing behaviors of these functions? Or is it simply an 
oversight on the part of the people who wrote Modules/_io/iobase.c?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Bryan Britten
Try to not sigh audibly as I ask what I'm sure are two asinine questions. 

1) How is this approach different from twtrDict = [json.loads(line) for line in 
urllib.urlopen(urlStr)]?

2) How do I tell how many JSON objects are on each line?



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


Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Denis McMahon
On Mon, 27 May 2013 14:29:38 -0700, Bryan Britten wrote:

 Try to not sigh audibly as I ask what I'm sure are two asinine
 questions.
 
 1) How is this approach different from twtrDict = [json.loads(line) for
 line in urllib.urlopen(urlStr)]?
 
 2) How do I tell how many JSON objects are on each line?

Your code at (1) creates a single list of all the json objects

The code you replied to loaded each object, assumed you did something 
with it, and then over-wrote it with the next one.

As for (2) - either inspection, or errors from the json parser.

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


Re: Encodign issue in Python 3.3.1 (once again)

2013-05-27 Thread Chris Angelico
On Tue, May 28, 2013 at 2:56 AM, Νίκος Γκρ33κ nikos.gr...@gmail.com wrote:
 Τη Δευτέρα, 27 Μαΐου 2013 6:52:32 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε:

 Oh, and you may want to hire a typist, too. At the moment, your posts
 make you appear not to care about the job.

 I always make typos when iam typing fast.

Yes, but then you don't go back and correct them before hitting Send,
which is what makes you appear to care very little. Typos in real-time
chat are understandable (though even on MUDs, most people tend to
broadcast less typos than your posts have, because even there there's
time to edit before hitting Enter), but with email, it's very easy to
spend 60 seconds glancing over your post before you send it. You're
using gmail, so chances are all you need to do is use a web browser
with a spellchecker and you'll catch all of the typos; I use Google
Chrome, and it has the now-prevalent red squiggly lines under all
suspected errors. (It's not perfect, of course; quite a few
correctly-spelled words are mistakenly flagged. But it's still pretty
effective at catching typos.)

You're effectively asking people to put in a few minutes' work,
sometimes quite a few minutes, to help you. Is it too much to hope
that you'll spend one more minute on your posts?

This is something that's utterly trivial, yet a window to your mind.
It's like boarding an airliner and finding coffee stains on the
flip-down trays - the plane flies just fine with those stains, yet the
impression they give is that the crew don't care about engine
maintenance either.

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


Re: Future standard GUI library

2013-05-27 Thread Chris Angelico
On Tue, May 28, 2013 at 3:13 AM, Michael Torrie torr...@gmail.com wrote:
 On 05/27/2013 09:31 AM, Wolfgang Keller wrote:
 HTTP handles that just fine, with your choice of XML,

 And XML is definitely not suitable as a marshalling format for a RPC
 protocol.

 XML-over-HTTP is a true cerebral flatulance of some hopelessly clueless
 moron.

 Hmm.  Well I think there are a lot of very smart developers that are
 using xml to marshal rpc and it's working fine.  So either they know
 something you don't, or maybe they are just busy making code that
 functions and functions pretty well, instead of making inflammatory
 statements on USENET.  Sure XML is not very efficient or compact, but it
 does handle unicode intrinsically through standard encodings, and a
 plethora of parsers makes it a decent choice.

I'll use XML when I have to, but if I'm inventing my own protocol,
nope. There are just too many quirks with it. How do you represent an
empty string named Foo?

Foo/Foo

or equivalently

Foo/

How do you represent an empty list named Foo? The same way. How do you
represent an empty dict/mapping named Foo? Lemme look up my
documentation... ah, the same way. Does this seem right to
you?/JubalEarly

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


Re: Future standard GUI library

2013-05-27 Thread Roy Smith
In article mailman.2265.1369693294.3114.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 I'll use XML when I have to, but if I'm inventing my own protocol,
 nope. There are just too many quirks with it. How do you represent an
 empty string named Foo?
 
 Foo/Foo
 
 or equivalently
 
 Foo/
 
 How do you represent an empty list named Foo? The same way. How do you
 represent an empty dict/mapping named Foo? Lemme look up my
 documentation... ah, the same way. Does this seem right to
 you?/JubalEarly

XML doesn't represent strings, or lists, or dicts.  It represents trees 
of nodes with labels.  If you wish to invent some richer semantic 
meaning to impose on those nodes, that's up to you.

JSON isn't better or worse than XML.  They solve different problems.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Fábio Santos
On 27 May 2013 22:36, Bryan Britten britten.br...@gmail.com wrote:

 Try to not sigh audibly as I ask what I'm sure are two asinine questions.

 1) How is this approach different from twtrDict = [json.loads(line) for
line in urllib.urlopen(urlStr)]?


The suggested approach made use of generators. Just because you can iterate
over something, that doesn't mean it is all in memory ;)

Check out the difference between range() and xrange() in python 2
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python error codes and messages location

2013-05-27 Thread Fábio Santos
On 27 May 2013 19:36, Fábio Santos fabiosantos...@gmail.com wrote:


 On 27 May 2013 19:23, Vito De Tullio vito.detul...@gmail.com wrote:
 
  Fábio Santos wrote:
 
   This should make life easier for us
  
http://docs.python.org/3/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy
  
   Speaking of PEPs and exceptions. When do we get localized exceptions?
 
  What do you mean by localized exceptions?
 
  Please, tell me it's *NOT* a proposal to send the exception message in
the
  locale language!
 
  --
  By ZeD
 
  --
  http://mail.python.org/mailman/listinfo/python-list

 It is. I think I read it mentioned in python-dev or this list.

Here is what I read.

http://mail.python.org/pipermail/python-dev/2013-April/125364.html

It wasn't only about exceptions after all. And it seems like something that
will only happen far into the future.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Dave Angel

On 05/27/2013 04:47 PM, Bryan Britten wrote:

Hey, everyone!

I'm very new to Python and have only been using it for a couple of days, but 
have some experience in programming (albeit mostly statistical programming in 
SAS or R) so I'm hoping someone can answer this question in a technical way, 
but without using an abundant amount of jargon.

The issue I'm having is that I'm trying to pull information from a website to 
practice Python with, but I'm having trouble getting the data in a timely 
fashion. If I use the following code:

code
import json
import urllib

urlStr = https://stream.twitter.com/1/statuses/sample.json;

twtrDict = [json.loads(line) for line in urllib.urlopen(urlStr)]
/code

I get a memory issue. I'm running 32-bit Python 2.7 with 4 gigs of RAM if that 
helps at all.


Which OS?

The first question I'd ask is how big this file is.  I can't tell, since 
it needs a user name  password to actually get the file.  But it's not 
unusual to need at least double that space in memory, and in Windoze 
you're limited to two gig max, regardless of how big your hardware might be.


If you separately fetch the file, then you can experiment with it, 
including cutting it down to a dozen lines, and see if you can deal with 
that much.


How could you fetch it?  With wget, with a browser (and saveAs), with a 
simple loop which uses read(4096) repeatedly and writes each block to a 
local file.  Don't forget to use 'wb', as you don't know yet what line 
endings it might use.


Once you have an idea what the data looks like, you can answer such 
questions as whether it's json at all, whether the lines each contain a 
single json record, or what.


For all we know, the file might be a few terabytes in size.


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


Re: Short-circuit Logic

2013-05-27 Thread Nobody
On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote:

 On Sunday, May 26, 2013 2:13:47 PM UTC+2, Steven D'Aprano wrote:

 What the above actually tests for is whether x is so small that (1.0+x)
 cannot be distinguished from 1.0, which is not the same thing. It is
 also quite arbitrary. Why 1.0? Why not (0.0001+x)? Or (0.0001+x)?
 Or (1.0+x)?
 
 That may be true for integers,

What may be true for integers?

 but for floats, testing for equality is not always precise

And your point is?

What Steven wrote is entirely correct: sys.float_info.epsilon is the
smallest value x such that 1.0 and 1.0+x have distinct floating-point
representations. It has no relevance for comparing to zero.

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


RE: Ldap module and base64 oncoding

2013-05-27 Thread Joseph L. Casale
 Note that all modules in python-ldap up to 2.4.10 including module 'ldif'
 expect raw byte strings to be passed as arguments. It seems to me you're
 passing a Unicode object in the entry dictionary which will fail in case an
 attribute value contains NON-ASCII chars.

Yup, I was.

 python-ldap expects raw strings since it's not schema-aware and therefore does
 not have any knowledge about the LDAP syntax used for a particular attribute
 type. So automagically convert Unicode strings will likely fail in many cases.
 = The calling application has to deal with it.

I see, that recco went a long a way in cleaning up my code actually and making 
the
handling of decoding and encoding more consistent.

 Don't muck with overriding  _unparseAttrTypeandValue(). Simply pass the
 properly encoded data into ldif module.

I had some time today, so I attempted to open the ldif files in binary mode to 
simply
work with the raw byte strings but the moment the first entry was parsed, 
parse()
stumbled on a character in the first entries dict and passed a dn of None for 
the last half?

If the option to avoid worrying about decoding and encoding could work, I would 
be
happy to process the whole lot in byte strings. Any idea what may cause this?

Thanks a lot Michael,
jlc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get an integer from a sequence of bytes

2013-05-27 Thread Steven D'Aprano
On Mon, 27 May 2013 11:30:18 -0400, Ned Batchelder wrote:

 On 5/27/2013 10:45 AM, Mok-Kong Shen wrote:
 From an int one can use to_bytes to get its individual bytes, but how
 can one reconstruct the int from the sequence of bytes?


 The next thing in the docs after int.to_bytes is int.from_bytes:

And I can't believe I missed that too :-(


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


RE: How to get an integer from a sequence of bytes

2013-05-27 Thread Carlos Nepomuceno

 From: steve+comp.lang.pyt...@pearwood.info
 Subject: Re: How to get an integer from a sequence of bytes
 Date: Mon, 27 May 2013 15:00:39 +
 To: python-list@python.org

 On Mon, 27 May 2013 16:45:05 +0200, Mok-Kong Shen wrote:

 From an int one can use to_bytes to get its individual bytes, but how
 can one reconstruct the int from the sequence of bytes?

 Here's one way:

 py n = 11999102937234
 py m = 0
 py for b in n.to_bytes(6, 'big'):
 ... m = 256*m + b
 ...
 py m == n
 True


 --
 Steven

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

Python 2 doesn't have to_bytes()! :(

# Python 2, LSB 1st
def to_lil_bytes(x):
    r = []
    while x != 0:
    r.append(int(x  0b))
    x= 8
    return r

# Python 2, LSB 1st
def from_lil_bytes(l):
    x = 0
    for i in range(len(l)-1, -1, -1):
    x = 8
    x |= l[i]
    return x

# Python 2, MSB 1st
def to_big_bytes(x):
    r = []
    while x != 0:
    r.insert(0, int(x  0b))
    x= 8
    return r

# Python 2, MSB 1st
def from_big_bytes(l):
    x = 0
    for i in range(len(l)):
    x = 8
    x |= l[i]
    return x

Can it be faster? 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get an integer from a sequence of bytes

2013-05-27 Thread Dave Angel

On 05/27/2013 08:31 PM, Steven D'Aprano wrote:

On Mon, 27 May 2013 11:30:18 -0400, Ned Batchelder wrote:


On 5/27/2013 10:45 AM, Mok-Kong Shen wrote:

 From an int one can use to_bytes to get its individual bytes, but how
can one reconstruct the int from the sequence of bytes?



The next thing in the docs after int.to_bytes is int.from_bytes:


And I can't believe I missed that too :-(



And that approach probably works for negative ints too.


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


Re: Total Beginner - Extracting Data from a Database Online (Screenshot)

2013-05-27 Thread logan . c . graham
On Saturday, May 25, 2013 6:33:25 PM UTC-7, John Ladasky wrote:
 On Friday, May 24, 2013 4:36:35 PM UTC-7, Carlos Nepomuceno wrote:
 
  #to create the tables list
 
  tables=[[re.findall('TD(.*?)/TD',r,re.S) for r in 
  re.findall('TR(.*?)/TR',t,re.S)] for t in 
  re.findall('TABLE(.*?)/TABLE',page,re.S)]
 
  
 
  
 
  Pretty simple. 
 
 
 
 Two nested list comprehensions, with regex pattern matching?
 
 
 
 Logan did say he was a total beginner.  :^)



Oh goodness, yes, I have no clue.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Total Beginner - Extracting Data from a Database Online (Screenshot)

2013-05-27 Thread Carlos Nepomuceno

 Date: Mon, 27 May 2013 17:58:00 -0700
 Subject: Re: Total Beginner - Extracting Data from a Database Online 
 (Screenshot)
 From: logan.c.gra...@gmail.com
 To: python-list@python.org
[...]

 Oh goodness, yes, I have no clue.

For example:

# to retrieve the contents of all column '# fb' (11th column from the image you 
sent)

c11 = [tables[0][r][10] for r in range(len(tables[0]))]
#      -
#  this is the content this is the quantity
#  of the 11th cell    of rows in table[0]
#  of row 'r' 
-- 
http://mail.python.org/mailman/listinfo/python-list


How to: Setuptools

2013-05-27 Thread ray
I would like to use easy_install, but can't figure out how to install it.

I have 64-bit Python 2.7.5 on Windows 7.  

Following the instructions on https://pypi.python.org/pypi/setuptools, it says:
Download ez_setup.py and run it; it will download the appropriate .egg file and 
install it for you. (Currently, the provided .exe installer does not support 
64-bit versions of Python for Windows, due to a distutils installer 
compatibility issue

Being new to Python, I don't know what it means to run it.  I am not sure 
what I am looking at when I open it as the first line is #!python.

Looking down into the content of ez_setup.py, I find:
'setuptools-0.6c10-py2.6.egg':
but there is no entry
'setuptools-0.6c10-py2.7.egg':

Searching for it, I found a version at:
https://pypi.python.org/packages/2.7/s/setuptools/

This appeared to be a linux version, the first line is:
#!/bin/sh
and the content seems to be encoded.

There is an exe at https://pypi.python.org/pypi/setuptools, but the 
instructions on the page state the .exe won't work for 64-bit installs.

Ray

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


Re: Future standard GUI library

2013-05-27 Thread Denis McMahon
On Tue, 28 May 2013 08:21:25 +1000, Chris Angelico wrote:

 I'll use XML when I have to, but if I'm inventing my own protocol,
 nope. There are just too many quirks with it. How do you represent an
 empty string named Foo?

 Foo/Foo

 or equivalently

 Foo/

 How do you represent an empty list named Foo? The same way. How do you
 represent an empty dict/mapping named Foo? Lemme look up my
 documentation... ah, the same way. Does this seem right to
 you?/JubalEarly

Foo type=list /
Foo type=mapping /
Foo type=string /

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


RE: How to: Setuptools

2013-05-27 Thread Carlos Nepomuceno
curl -O http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py


 Date: Mon, 27 May 2013 18:32:43 -0700
 Subject: How to: Setuptools
 From: r...@aarden.us
 To: python-list@python.org

 I would like to use easy_install, but can't figure out how to install it.

 I have 64-bit Python 2.7.5 on Windows 7.

 Following the instructions on https://pypi.python.org/pypi/setuptools, it 
 says:
 Download ez_setup.py and run it; it will download the appropriate .egg file 
 and install it for you. (Currently, the provided .exe installer does not 
 support 64-bit versions of Python for Windows, due to a distutils installer 
 compatibility issue

 Being new to Python, I don't know what it means to run it. I am not sure 
 what I am looking at when I open it as the first line is #!python.

 Looking down into the content of ez_setup.py, I find:
 'setuptools-0.6c10-py2.6.egg':
 but there is no entry
 'setuptools-0.6c10-py2.7.egg':

 Searching for it, I found a version at:
 https://pypi.python.org/packages/2.7/s/setuptools/

 This appeared to be a linux version, the first line is:
 #!/bin/sh
 and the content seems to be encoded.

 There is an exe at https://pypi.python.org/pypi/setuptools, but the
 instructions on the page state the .exe won't work for 64-bit installs.

 Ray

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


RE: Minor consistency question in io.IOBase

2013-05-27 Thread Carlos Nepomuceno

 Date: Mon, 27 May 2013 14:22:17 -0700
 Subject: Minor consistency question in io.IOBase
 From: dwight.g...@gmail.com
 To: python-list@python.org

 Hi, so, I don't necessarily know if this is the right place to ask this 
 question since it's kindof a rather technical one which gets into details of 
 the python interpreter itself, but I thought I'd start here and if nobody 
 knew the answer, they could let me know if it makes sense to ask on 
 python-dev.

 I am wondering why it is that the default implementations of certain of the 
 mixin methods on IOBase seem to behave somewhat inconsistently. 
 Specifically, the behavior of precisely when in the pipeline a method checks 
 to see whether the object is already closed seems to be inconsistent.

 In the following methods:

 IOBase.__next__
 IOBase.readline
 IOBase.tell

 In each case, these methods never check to see whether the file is closed. 
 __next__ immediately calls readline(), readline(limit) calls read(1) at most 
 limit times, and tell calls seek(0, 1). It is relying on the underlying 
 method to raise a ValueError if the file is already closed. Otherwise, 
 __next__ and readline will raise AttributeErrors on unreadable files, and 
 tell will raise an UnsupportedOperation on unseekable files. A side effect of 
 this is that readline(0) on a closed file will succeed.

According to [1]  [2] it's a bug! Report the issue: http://bugs.python.org/

close()
Flush and close this stream. This method has no effect if the file is already 
closed. Once the file is closed, any operation on the file (e.g. reading or 
writing) will raise a ValueError.

[1] http://docs.python.org/2/library/io.html#i-o-base-classes
[2] http://docs.python.org/3.3/library/io.html#i-o-base-classes 
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to: Setuptools

2013-05-27 Thread rusi
On May 28, 6:45 am, Carlos Nepomuceno carlosnepomuc...@outlook.com
wrote:
 curl -Ohttp://peak.telecommunity.com/dist/ez_setup.py
 python ez_setup.py

Curl comes built into windows??
Does not seem so...
http://serverfault.com/questions/483754/is-there-a-built-in-command-line-tool-under-windows-like-wget-curl

Also given that the question clearly says 'I dont know what it means
to run it '
I think your two lines could be too cryptic :-)

To the OP: Sorry I am not being very helpful to you -- I am not on
windows now and dont know these commands offhand

I am sure someone else will chime in..
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: How to: Setuptools

2013-05-27 Thread Carlos Nepomuceno

 Date: Mon, 27 May 2013 19:57:47 -0700
 Subject: Re: How to: Setuptools
 From: rustompm...@gmail.com
 To: python-list@python.org

 On May 28, 6:45 am, Carlos Nepomuceno carlosnepomuc...@outlook.com
 wrote:
 curl -Ohttp://peak.telecommunity.com/dist/ez_setup.py
 python ez_setup.py

 Curl comes built into windows??

No, but you can get it from http://curl.haxx.se/download.html

 Does not seem so...
 http://serverfault.com/questions/483754/is-there-a-built-in-command-line-tool-under-windows-like-wget-curl

 Also given that the question clearly says 'I dont know what it means
 to run it '
 I think your two lines could be too cryptic :-)

Perhaps, my grandma used to think English is very cryptic. ;)

 To the OP: Sorry I am not being very helpful to you -- I am not on
 windows now and dont know these commands offhand

 I am sure someone else will chime in..
 --
 http://mail.python.org/mailman/listinfo/python-list   
   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading *.json from URL - json.loads() versus urllib.urlopen.readlines()

2013-05-27 Thread Bryan Britten
On Monday, May 27, 2013 7:58:05 PM UTC-4, Dave Angel wrote:
 On 05/27/2013 04:47 PM, Bryan Britten wrote:
 
  Hey, everyone!
 
 
 
  I'm very new to Python and have only been using it for a couple of days, 
  but have some experience in programming (albeit mostly statistical 
  programming in SAS or R) so I'm hoping someone can answer this question in 
  a technical way, but without using an abundant amount of jargon.
 
 
 
  The issue I'm having is that I'm trying to pull information from a website 
  to practice Python with, but I'm having trouble getting the data in a 
  timely fashion. If I use the following code:
 
 
 
  code
 
  import json
 
  import urllib
 
 
 
  urlStr = https://stream.twitter.com/1/statuses/sample.json;
 
 
 
  twtrDict = [json.loads(line) for line in urllib.urlopen(urlStr)]
 
  /code
 
 
 
  I get a memory issue. I'm running 32-bit Python 2.7 with 4 gigs of RAM if 
  that helps at all.
 
 
 
 Which OS?

I'm operating on Windows 7.

 
 The first question I'd ask is how big this file is.  I can't tell, since 
 
 it needs a user name  password to actually get the file.  

If you have Twitter, you can just use your log-in information to access the 
file.

 But it's not unusual to need at least double that space in memory, and in 
 Windoze 
 
 you're limited to two gig max, regardless of how big your hardware might be.
 
 
 
 If you separately fetch the file, then you can experiment with it, 
 
 including cutting it down to a dozen lines, and see if you can deal with 
 
 that much.
 
 
 
 How could you fetch it?  With wget, with a browser (and saveAs), with a 
 
 simple loop which uses read(4096) repeatedly and writes each block to a 
 
 local file.  Don't forget to use 'wb', as you don't know yet what line 
 
 endings it might use.
 
I'm not familiar with using read(4096), I'll have to look into that. When I 
tried to just save the file, my computer just sat in limbo for some time and 
didn't seem to want to process the command. 
 
 Once you have an idea what the data looks like, you can answer such 
 
 questions as whether it's json at all, whether the lines each contain a 
 
 single json record, or what.
 
Based on my *extremely* limited knowledge of JSON, that's definitely the type 
of file this is. Here is a snippet of what is seen when you log in:

{created_at:Tue May 28 03:09:23 + 
2013,id:339216806461972481,id_str:339216806461972481,text:RT 
@aleon_11: Sigo creyendo que las noches lluviosas me acercan mucho m\u00e1s a 
ti!,source:\u003ca href=\http:\/\/blackberry.com\/twitter\ 
rel=\nofollow\\u003eTwitter for 
BlackBerry\u00ae\u003c\/a\u003e,truncated:false,in_reply_to_status_id:null,in_reply_to_status_id_str:null,in_reply_to_user_id:null,in_reply_to_user_id_str:null,in_reply_to_screen_name:null,user:{id:310910123,id_str:310910123,name:\u2661,screen_name:LaMarielita_,location:,url:null,description:MERCADOLOGA
  PUBLICISTA EN PROCESO, AMO A MI DIOS  MI FAMILIA\u2665 ME ENCANTA REIRME , 
MOLESTAR  HABLAR :D BFF, pancho, ale  china :) 
LY\u2661,protected:false,followers_count:506,friends_count:606,listed_count:1,created_at:Sat
 Jun 04 15:24:19 + 
2011,favourites_count:207,utc_offset:-25200,time_zone:Mountain Time (US 
 Canada),geo_enabled:false,
 
verified:false,statuses_count:17241,lang:es,contributors_enabled:false,is_translator:false,profile_background_color:FF6699,profile_background_image_url:http:\/\/a0.twimg.com\/images\/themes\/theme11\/bg.gif,profile_background_image_url_https:https:\/\/si0.twimg.com\/images\/themes\/theme11\/bg.gif,profile_background_tile:true,profile_image_url:http:\/\/a0.twimg.com\/profile_images\/3720425493\/13a48910e56ca34edeea07ff04075c77_normal.jpeg,profile_image_url_https:https:\/\/si0.twimg.com\/profile_images\/3720425493\/13a48910e56ca34edeea07ff04075c77_normal.jpeg,profile_link_color:B40B43,profile_sidebar_border_color:CC3366,profile_sidebar_fill_color:E5507E,profile_text_color:362720,profile_use_background_image:true,default_profile:false,default_profile_image:false,following:null,follow_request_sent:null,notifications:null},geo:null,coordinates:null,place:null,contributors:null,retweeted_status:{created_at:Tue
 May 2
 8 02:57:40 + 
2013,id:339213856922537984,id_str:339213856922537984,text:Sigo 
creyendo que las noches lluviosas me acercan mucho m\u00e1s a 
ti!,source:web,truncated:false,in_reply_to_status_id:null,in_reply_to_status_id_str:null,in_reply_to_user_id:null,in_reply_to_user_id_str:null,in_reply_to_screen_name:null,user:{id:105252134,id_str:105252134,name:Alejandra
 
Le\u00f3n,screen_name:aleon_11,location:Guatemala,url:null,description:La
 vida se disfruta m\u00e1s, cuando no se le pone tanta 
importancia.,protected:false,followers_count:143,friends_count:251,listed_count:0,created_at:Fri
 Jan 15 20:49:38 + 
2010,favourites_count:83,utc_offset:-28800,time_zone:Pacific Time (US  

Re: How to: Setuptools

2013-05-27 Thread rusi
On May 28, 8:06 am, Carlos Nepomuceno carlosnepomuc...@outlook.com
wrote:
 

  Date: Mon, 27 May 2013 19:57:47 -0700
  Subject: Re: How to: Setuptools
  From: rustompm...@gmail.com
  To: python-l...@python.org

  On May 28, 6:45 am, Carlos Nepomuceno carlosnepomuc...@outlook.com
  wrote:
  curl -Ohttp://peak.telecommunity.com/dist/ez_setup.py
  python ez_setup.py

  Curl comes built into windows??

 No, but you can get it fromhttp://curl.haxx.se/download.html

Oooff! Talk of using sledgehammers to crack nuts...

All that is needed is to visit http://peak.telecommunity.com/dist/ez_setup.py
with the browser and to save the file!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I want to know how to implement concurrent threads in Python

2013-05-27 Thread Daniel Gagliardi
fuck! fuck! i'm gonna be fired if i didnt get this shit! i told my boss id
do it. fuck! im gonna pipe some crakc. fuck...


2013/5/26 Mark Lawrence breamore...@yahoo.co.uk

 On 26/05/2013 20:10, Daniel Gagliardi wrote:

 I want to know how to implement concurrent threads in Python


 google, bing, duckduckgo, yahoo...


 --
 If you're using GoogleCrap™ please read this http://wiki.python.org/moin/*
 *GoogleGroupsPython http://wiki.python.org/moin/GoogleGroupsPython.

 Mark Lawrence

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

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


RE: How to: Setuptools

2013-05-27 Thread Carlos Nepomuceno

 Date: Mon, 27 May 2013 20:54:53 -0700
 Subject: Re: How to: Setuptools
 From: rustompm...@gmail.com
[...]

 Oooff! Talk of using sledgehammers to crack nuts...

 All that is needed is to visit http://peak.telecommunity.com/dist/ez_setup.py
 with the browser and to save the file!!

Can you show me how to do that from a batch file? Please... 
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python error codes and messages location

2013-05-27 Thread Vito De Tullio
Fábio Santos wrote:

   Speaking of PEPs and exceptions. When do we get localized exceptions?
 
  What do you mean by localized exceptions?
 
  Please, tell me it's *NOT* a proposal to send the exception message in
  the
  locale language!
 It is. I think I read it mentioned in python-dev or this list.
 
 Here is what I read.
 
 http://mail.python.org/pipermail/python-dev/2013-April/125364.html
 
 It wasn't only about exceptions after all. And it seems like something
 that will only happen far into the future.

I really hope really far... have you never tried to google a localized error 
message? :\

-- 
By ZeD

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


Re: How to: Setuptools

2013-05-27 Thread rusi
On May 28, 9:09 am, Carlos Nepomuceno carlosnepomuc...@outlook.com
wrote:
 

  Date: Mon, 27 May 2013 20:54:53 -0700
  Subject: Re: How to: Setuptools
  From: rustompm...@gmail.com
 [...]

  Oooff! Talk of using sledgehammers to crack nuts...

  All that is needed is to visithttp://peak.telecommunity.com/dist/ez_setup.py
  with the browser and to save the file!!

 Can you show me how to do that from a batch file? Please...

What in the OP's question translates into a need for a batch-file?

And you are proposing that he downloads curl just to write that batch-
file?!?!

How come that proposal is not subject to the same requirement, viz. I
dont see in your recipe any:
Here-is-a-batchfile-to-download-curl-without-curl?
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue18050] embedded interpreter or virtualenv fails with ImportError: cannot import name MAXREPEAT

2013-05-27 Thread Ned Deily

Ned Deily added the comment:

After spending some time investigating this issue, I believe that potential 
upgrade compatibility issues have been introduced by the changes for 
Issue13169.  How critical they are and, in particular, whether they violate our 
implicit promises of maintenance (point) release compatibility are questions 
for discussion.

The signature of the problem is ImportError: cannot import name MAXREPEAT as 
a result of an attempt to import re or a module that itself imports re:

Traceback (most recent call last):
  File stdin, line 1, in module
  File /home/nad/issue18050/u/lib/python2.7/re.py, line 105, in module
import sre_compile
  File /home/nad/issue18050/u/lib/python2.7/sre_compile.py, line 14, in 
module
import sre_parse
  File /home/nad/issue18050/u/lib/python2.7/sre_parse.py, line 17, in module
from sre_constants import *
  File /home/nad/issue18050/u/lib/python2.7/sre_constants.py, line 18, in 
module
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT

The changes for Issue13169 moved the definition of MAXREPEAT into C code and 
then added an import of the new C constant into Lib/sre_constants.py to 
continue to provide sre_constants.MAXREPEAT for third-party modules that have 
been using it.  As long as the versions of the Python interpreter and the 
standard library Python files (sys.prefix/lib/pythonX.Y) remain in sync, there 
is not a problem.  However, if a situation arises where a pre-13169 interpreter 
is used with a post-13169 standard library, the cannot import name MAXREPEAT 
ImportError will occur.  I have found at least two situations where this can 
happen:

1. when a C application has statically embedded a pre-13169 interpreter and the 
standard library pointed to by its sys.prefix gets upgraded to a post-13169 
version.  The interpreter then crashes during initialization in Lib/site.py 
which imports re in both Python 2 and 3 (for different purposes).

2. when a virtualenv created with a pre-13169 non-shared interpreter is used 
with an upgraded post-13169 standard library.  In this case, the interpreter 
makes it past initialization because virtualenv (at least, the current version) 
creates a modified site.py in the virtualenv lib/pythonX.Y that happens to not 
import re.  However, the import error will occur on the first use of re.  Side 
note: 3.3 standard library pyvenv does not seem to have this problem since the 
created venv symlinks to the sys.prefix interpreter and libs rather than 
copying it, like virtualenv does.

Note that Pythons built with --enable-shared (or --enable-framework on OS X) 
generally will not have a problem as long as the shared libpythonX.Y and the 
standard library remain consistent.  That is, in both cases above, a Python 
upgrade will automatically cause both the embedded app and the virtualenv to 
run with the newer interpreter.  AFAICT, the problems will only be seen when 
using a non-shared Python.

I believe the upgrades affected by this problem are:

2.7 through 2.7.3 upgraded to 2.7.4 or 2.7.5
3.3.0 upgraded to 3.3.1 or 3.3.2
3.2 through 3.2.3 upgraded to 3.2.4 or 3.2.5 (unverified)

The problem should be fixable by applying a patch along the lines suggested by 
Samuel.  Regardless of whether this is a compatibility break or not, I think we 
should fix the problem because people are already running into it.  (Nosying 
the release managers for their input.)

While related, the root cause of the vim problem reported above is probably 
more complicated because, although it appears to embed a Python interpreter, 
the standard library used by the OS X system vim appears to depend on $PATH, 
apparently incorrect behavior in vim.  Unfortunately, OS X vim users on 10.8 
(probably also on 10.7) may encounter this problem when they try to use :py if 
they install an updated version of Python 2.7, such as from python.org or a 
third-party distributor like Homebrew or MacPorts.  And, when vim crashes due 
to the import error, it leaves the terminal settings in an unusable state.  One 
user workaround might be to create a shell function or alias to tweak PATH 
before using vim to ensure /usr/bin/python2.7 is found first.  Or simply patch 
re.py in the upgraded Python.

--
components: +Library (Lib) -Extension Modules
nosy: +benjamin.peterson, georg.brandl, serhiy.storchaka
priority: normal - high
stage:  - needs patch
title: _sre.MAXREPEAT not defined in 2.7.3 - embedded interpreter or 
virtualenv fails with ImportError: cannot import name MAXREPEAT
versions: +Python 3.3, Python 3.4

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



[issue18032] set methods should specify whether they consume iterators lazily

2013-05-27 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
assignee: docs@python - rhettinger
nosy: +rhettinger

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



[issue18032] set methods should specify whether they consume iterators lazily

2013-05-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

We don't normally document implementation details or the presences or absence 
of internal optimizations.  This gives us freedom to change the implementation 
and it allows freedom for other implementations (such as Jython, IronPython, 
and PyPy) to make their own choices.  Often those implementations start out 
with the simplest correct approach and then become increasingly optimized over 
time. 

I'm leaving this one open as a possible CPythhon performance enhancement, 
adding early-out behavior to issubset() when the argument is a non-set, 
non-dict iterable:

def issubset(self, iterable):
n = len(self)
seen = set() 
for x in iterable:
if x not in seen and x in self:
seen.add(x)
n -= 1
if not n:
return True # early-out
return False

--
components: +Interpreter Core -Documentation
type: behavior - performance
versions:  -Python 2.7, Python 3.3

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



[issue1747670] Limiting data copy in xmlrpclib

2013-05-27 Thread Gael Le Mignot

Gael Le Mignot added the comment:

It's not something that can be easily benched because it depends a lot of the 
use case. If some conditions are present (big amount of data sent to XML-RPC, 
the XML-RPC server taking a long time to answer, end either Python giving back 
the memory to the OS or another thread reusing the garbage collected memory) 
the gain in memory can be very significant, in most other cases, it won't 
change anything. 

Do you me to craft a simple example where the difference can be seen ?

--

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



[issue18047] Descriptors get invoked in old-style objects and classes

2013-05-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

IMO nothing should change here (either the docs or the implementation).

The OP has observed an implementation detail of old-style classes (which were 
reimplemented in Python 2.2 using descriptor logic instead of their former 
hard-wired behaviors).

--
nosy: +rhettinger

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



[issue1747670] Limiting data copy in xmlrpclib

2013-05-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Yes, it would be nice if you provided an example.

--

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



[issue18069] Subprocess picks the wrong executable on Windows

2013-05-27 Thread berdario

berdario added the comment:

I found out what's the problem, from the CreateProcess docs:

http://msdn.microsoft.com/en-us/library/ms682425.aspx


If the file name does not contain a directory path, the system searches for the 
executable file in the following sequence:
The directory from which the application loaded.
The current directory for the parent process.
[...]


This means that subprocess.Popen (and related functions) will always pick an 
executable in C:\PythonXX (if launched from the interpreter) or from 
C:\PythonXX\Scripts (if launched from a script/executable installed there) 
before looking into the PATH.

If we want to have the same behavior on *nix platforms and windows, I think 
that the only way this can be fixed, is by filtering the executable and 
args arguments through shutil.which (or a similar approach)

Otherwise, the difference in the executable path resolution should be 
documented.

(Either way, in my application, I'll have to reimplement shutil.which to be 
able to work on older python versions )

--

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



[issue672115] Assignment to __bases__ of direct object subclasses

2013-05-27 Thread Łukasz Langa

Changes by Łukasz Langa luk...@langa.pl:


--
versions: +Python 3.4 -Python 2.7, Python 3.1, Python 3.2

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



[issue672115] Assignment to __bases__ of direct object subclasses

2013-05-27 Thread Łukasz Langa

Changes by Łukasz Langa luk...@langa.pl:


--
nosy: +lukasz.langa

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



[issue18050] embedded interpreter or virtualenv fails with ImportError: cannot import name MAXREPEAT

2013-05-27 Thread Julian Berman

Changes by Julian Berman julian+python@grayvines.com:


--
nosy: +Julian

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



[issue18050] embedded interpreter or virtualenv fails with ImportError: cannot import name MAXREPEAT

2013-05-27 Thread Samuel John

Samuel John added the comment:

Ned, incredibly helpful description. Thanks for investigating! I have nothing 
to add to that.

--

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



[issue15745] Numerous utime ns tests fail on FreeBSD w/ ZFS (update: and NetBSD w/ FFS, Solaris w/ UFS)

2013-05-27 Thread Ed Maste

Changes by Ed Maste carpedd...@gmail.com:


--
nosy: +Ed.Maste

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



[issue18070] change importlib.util.module_for_loader to unconditionally set attributes

2013-05-27 Thread Brett Cannon

New submission from Brett Cannon:

importlib.util.module_for_loader (as well as set_package and set_loader) only 
set those attributes either when they are not already set or when the module is 
new. I realized this is a problem as it means a reload won't work the way one 
might expect.

I want to at least change module_for_loader since I suspect that is in wider 
use, but probably all three decorators to unconditionally set their respective 
attributes so reloads operate as expected. Unfortunately that is 
backwards-incompatible, albeit for probably a rare case if anyone actually 
cares.

Anyone see a reason why doing this is a bad idea and it shouldn't be done?

--
components: Library (Lib)
messages: 190139
nosy: barry, brett.cannon, eric.smith, eric.snow, ncoghlan
priority: normal
severity: normal
stage: test needed
status: open
title: change importlib.util.module_for_loader to unconditionally set attributes
type: behavior
versions: Python 3.4

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



[issue18071] _osx_support compiler_fixup

2013-05-27 Thread Samuel John

New submission from Samuel John:

In the `_osx_support.py` module, there seems to be a bug in the method 
`compiler_fixup` which occurs if 

* the `customize_compiler` method from `distutils/sysconfig` has been called 
and after that
* `_compile` from `distutils/unixcompiler.py` is called. The `_compile` method 
uses `_osx_support.compiler_fixup`.

The critical line in compiler_fixup is:

`compiler_so = list(compiler_so)`.

Usually `compiler_so` is a list like `['cc']` but not when `customize_compiler` 
(from sysconfig) has been called. The value returned by 
`sysconfig.get_config_var('LDSHARED')` is a unicode like for example in the 
case of a Python 2.7.5 built via Homebrew: 
  
cc -bundle -undefined dynamic_lookup -L/homebrew/lib 
-L/homebrew/opt/sqlite/lib -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk.
When `list()` is applied to the value, it is split at each character and that 
cannot be intended.

I am not sure if I fully understand, but to fix this in `compiler_fixup`, 
instead of `compiler_so = list(compiler_so)`, I'd propose something along the 
lines of:

if isinstance(compiler_so, (str,unicode)):
compiler_so = compiler_so.split()

I found this by trying to `pip install cython` (it uses customize_compiler, I 
guess) on a homebrewed python.

To reproduce in an interactive shell we can emulate what is going on by calling 
`compiler_fixup` directly with the values sysconfig has stored. The exact 
string does not matter, because I think the any value returned by 
`sysconfig_get_config_var` is a (unicode) string and not a list:

import sysconfig
import _osx_support

_osx_support.compiler_fixup(sysconfig.get_config_var('LDSHARED'),sysconfig.get_config_var('CFLAGS'))


Not sure if other python versions are affected. I wasn't aware of 
`_osx_support` at all until now.

--
assignee: ronaldoussoren
components: Macintosh
messages: 190140
nosy: hynek, ned.deily, ronaldoussoren, samueljohn
priority: normal
severity: normal
status: open
title: _osx_support compiler_fixup
versions: Python 2.7

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



[issue18071] _osx_support compiler_fixup

2013-05-27 Thread Samuel John

Samuel John added the comment:

The symptom for the end-user looks kind of weird:

running build_ext
building 'Cython.Plex.Scanners' extension
/ A p p l i c a t i o n s / X c o d e . a p p / C o n t e n t s / D e v e l o p 
e r / T o o l c h a i n s / X c o d e D e f a u l t . x c t o o l c h a i n / u 
s r / b i n / c l a n g   - f n o - s t r i c t - a l i a s i n g   - f n o - c 
o m m o n   - d y n a m i c   - I / h o m e b r e w / i n c l u d e   - I / h o 
m e b r e w / o p t / s q l i t e / i n c l u d e   - i s y s r o o t   / A p p 
l i c a t i o n s / X c o d e . a p p / C o n t e n t s / D e v e l o p e r / P 
l a t f o r m s / M a c O S X . p l a t f o r m / D e v e l o p e r / S D K s / 
M a c O S X 1 0 . 8 . s d k   - I / A p p l i c a t i o n s / X c o d e . a p p 
/ C o n t e n t s / D e v e l o p e r / P l a t f o r m s / M a c O S X . p l a 
t f o r m / D e v e l o p e r / S D K s / M a c O S X 1 0 . 8 . s d k / S y s t 
e m / L i b r a r y / F r a m e w o r k s / T k . f r a m e w o r k / V e r s i 
o n s / 8 . 5 / H e a d e r s   - D N D E B U G   - g   - f w r a p v   - O 3   
- W a l l   - W s t r i c t - p r o t 
 o t y p e s   
-I/homebrew/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7
 -c Cython/Plex/Scanners.c -o 
build/temp.macosx-10.8-x86_64-2.7/Cython/Plex/Scanners.o
unable to execute /: Permission denied
error: command '/' failed with exit status 1


Pasted here to help googlers to find it :-)

--

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



  1   2   >