Re: Removing matching items from a list?

2013-08-04 Thread Christian Gollwitzer

Hi Kevin,

Am 04.08.13 02:38, schrieb kevin4f...@gmail.com:

Sorry for the repeated messages. I have no idea why I have such a
long time delay. My messages didn't appear until just now after a few
minutes (thought I was having some issues).



you are posting to newsgroups from the USENET. It is typical that your 
posts need some time, and more time is needed for the message to show up 
*for other people* - many people see your message only after an hour or 
similar.


Concerning your question,

 Let's say there's 4 a's taken out. The list would show:
 ['a']

 But if there was also 4 j's in addition to the 4 a's, it would go:
 ['a', 'j']

well, when you take them out, as Steven has shown, you can also store 
them in an additional list, like


takeouts.append(removedchar)

If you are only interested in the number, you could count the items in 
the original list and subtract the number of items in you final list.


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


Re: PEP8 revised: max line lengths

2013-08-04 Thread wxjmfauth
Le samedi 3 août 2013 13:35:29 UTC+2, Nicholas a écrit :
 On Friday, 2 August 2013, Chris “Kwpolska” Warrick  wrote:
 
 
 [snip]
 
 
 
 So, what are you feasting for?  Nothing?
 
 
 I have long since ceased to be amazed at the number of people who would like 
 their personal and arbitrary preferences, and the rationalisations that go 
 with them, to be validated and endorsed by others, in law if possible and in 
 policy documents if not!

--

I have always found, computer scientists are funny scientists.


- They do love to solve the problems, they created themselves.

- They have the tendency to take the consequences as
the causalities.

- And they forget:

i)p  = q   ==   not(q) = not(p)

ii)   To proof a law is correct, one has to proof it's correct
in all cases. To proof a law is incorrect, it is enough to
find one, and solelely one, case showing the law is incorrect.


In my computing experience, the Python world is really shining
on these points.

jmf

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


Re: outputting time in microseconds or milliseconds

2013-08-04 Thread matt . doolittle33
ok so now i import the module like this:

   from time import strftime, time

i made the write statement like this:

   self.logfile.write('%s\t'%(str(strftime(%Y-%m-%d, 
   self.logfile.write('%s\t'%(str(strftime(%H:%M:%S, 
   self.logfile.write('%s\t'%(str(time(

(oh and btw,i know the code is hacker ugly).  
and the output is this:

2013-08-03  23:59:341375588774.89
2013-08-03  23:59:351375588775.06
2013-08-03  23:59:351375588775.25
2013-08-03  23:59:351375588775.43
2013-08-03  23:59:351375588775.80
2013-08-03  23:59:351375588775.99
2013-08-03  23:59:351375588775.99
2013-08-03  23:59:351375588775.99
2013-08-03  23:59:351375588776.00
2013-08-03  23:59:361375588776.15
2013-08-03  23:59:361375588776.15
2013-08-03  23:59:361375588776.16
2013-08-03  23:59:361375588776.16
2013-08-03  23:59:361375588776.16
2013-08-03  23:59:361375588776.16
2013-08-03  23:59:361375588776.16
2013-08-03  23:59:361375588776.16
2013-08-03  23:59:361375588776.16
2013-08-03  23:59:361375588776.34
2013-08-03  23:59:361375588776.35
2013-08-03  23:59:361375588776.35
2013-08-03  23:59:361375588776.35

the first two columns are for eyes so if they are a microsecond apart it 
doesn't matter. the numbers in the third column are for calculating duration 
which is where i need the precision. 

Why is it only giving me the centisecond precision?  the docs say i should get 
microsecond precision with the code i put together.

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


Re: outputting time in microseconds or milliseconds

2013-08-04 Thread Alain Ketterlin
matt.doolittl...@gmail.com writes:

self.logfile.write('%s\t'%(str(time(
[...]
 2013-08-0323:59:341375588774.89
[...]
 Why is it only giving me the centisecond precision? the docs say i
 should get microsecond precision with the code i put together.

Because of str()'s default format. Use %f % (time()) (and maybe vary
the precision).

-- Alain.

P/S: using str() + string formatting is kind of overkill: either use
string format directives like %f, or use str() with simple string
concatenation -- the latter giving less control.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Minions are Python Powered!

2013-08-04 Thread Kevin MacPhail
This statement might be more true than you realize.

I can't speak for the tools Blue Sky uses for their films, but when the
studio I worked at created the Minion Mayem ride for Universal Orlando we
used a number of tools that relied heavily on Python for everything from
character rigging to rendering and compositing.

I think it would be fair to say the Minions (and most animated characters
these days) are quite literally Python Powered.

BTW, great image!


On Sat, Aug 3, 2013 at 7:16 AM, Borja Morales realit...@gmail.com wrote:

 Everytime I watched the minions from Despicable Me something was hitting
 my unconscious mind. Finally I figured it out... Minions are Python Powered!

 I couldn't resist to make an image :)


 https://www.dropbox.com/s/t8kaba619vi6q82/minion_powered_by_python_reality3d.jpg
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: outputting time in microseconds or milliseconds

2013-08-04 Thread Dave Angel
matt.doolittl...@gmail.com wrote:

 ok so now i import the module like this:

from time import strftime, time

 i made the write statement like this:

self.logfile.write('%s\t'%(str(strftime(%Y-%m-%d, 
self.logfile.write('%s\t'%(str(strftime(%H:%M:%S, 
self.logfile.write('%s\t'%(str(time(

 (oh and btw,i know the code is hacker ugly).  
 and the output is this:

 2013-08-0323:59:341375588774.89
 2013-08-0323:59:351375588775.06
 2013-08-0323:59:351375588775.25
 2013-08-0323:59:351375588775.43
 2013-08-0323:59:351375588775.80
 2013-08-0323:59:351375588775.99
 2013-08-0323:59:351375588775.99
 2013-08-0323:59:351375588775.99
 2013-08-0323:59:351375588776.00
 2013-08-0323:59:361375588776.15
 2013-08-0323:59:361375588776.15
 2013-08-0323:59:361375588776.16
 2013-08-0323:59:361375588776.16
 2013-08-0323:59:361375588776.16
 2013-08-0323:59:361375588776.16
 2013-08-0323:59:361375588776.16
 2013-08-0323:59:361375588776.16
 2013-08-0323:59:361375588776.16
 2013-08-0323:59:361375588776.34
 2013-08-0323:59:361375588776.35
 2013-08-0323:59:361375588776.35
 2013-08-0323:59:361375588776.35

 the first two columns are for eyes so if they are a microsecond apart it 
 doesn't matter.

But if the time is close enough to midnight, they'll be a *day* apart,
as I (and others) said before. It's also hard to imagine why you
resist the good advice you've been getting about formatting. You can
do both the date and time with one call to strftime().

 the numbers in the third column are for calculating duration which is
 where i need the precision. 

 Why is it only giving me the centisecond precision?  the docs say i should 
 get microsecond precision with the code i put together.


Have you done any experimenting to decide which logic was losing those
extra digits?  Sit in the debugger, and do a  t = time.time()

Then investigate what t looks like, 
by repr(t), str(t), and something %t

(for various values of something)


from time import time, localtime, strftime

now = time()   #make a single call to get the time in seconds (float)
localnow = localtime(now)

out12 = strftime(%Y-%m-%d\t%H:%M:%S\t, localnow)
out3 = %.6f % now
self.logfile.write(out12 + out3)

You still have the problem that out12 is in the local time zone, while
out3 is in DCT.  But as you say, these are for different audiences, and
presumably you won't really be putting them in the same file.

-- 
DaveA

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


Re: PEP8 revised: max line lengths

2013-08-04 Thread Roy Smith
In article d2e561f1-f5ba-4242-941d-6989abd1a...@googlegroups.com,
 wxjmfa...@gmail.com wrote:

 I have always found, computer scientists are funny scientists.

I have always found that sciences which contain the word science in 
their name tend to not be very scientific.

Biology, Chemistry, Physics, those are real sciences.  Computer Science, 
Social Science, Political Science, not so much.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP8 revised: max line lengths

2013-08-04 Thread Sergi Pasoev
Let's say computer science isn't science. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP8 revised: max line lengths

2013-08-04 Thread Sergi Pasoev
What about Earth Science? But in this case, it is indeed science,
because in its name the word science is applied to the object of its
study. But in the case of computer science, the word science is
applied to the word which describes the tool this science uses!! It's
like it was Telescope Science in the name of astronomy. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modeling life on Earth –- an object-oriented (Python?) challenge

2013-08-04 Thread David Hutto
You basically have, currently, widgets,data,data manipulation through
variables and widget utilization to call the functions,and data
visualization.

Next step would be algorithm, and pseudo code, plus a prototyped mockup of
the GUI.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: outputting time in microseconds or milliseconds

2013-08-04 Thread Roy Smith
In article 07f6b1c7-069d-458b-a9fe-ff30c09f2...@googlegroups.com,
 matt.doolittl...@gmail.com wrote:

 self.logfile.write('%s\t'%(str(time(
 [...]
 1375588774.89
 [...]
 Why is it only giving me the centisecond precision?  the docs say i should 
 get microsecond precision

When citing documentation, it's a good idea to provide a link to the 
docs page, and/or a direct quote of what you read.

I'm looking at http://docs.python.org/2/library/time.html#time.time, 
which says, not all systems provide time with a better precision than 1 
second.  So, I don't know where you got the impression that you're 
guaranteed microsecond precision.

Earlier in the thread, you did mention that you're on Ubuntu, and there 
you do indeed get pretty good precision.  I'm not 100% sure if it's good 
to the microsecond (it appears to be), but it's certainly better than 
centisecond.

Anyway, your problem appears to be that str(float) gives you two digits 
after the decimal (at least for values in the range we're talking about 
here), but repr() will give you more:

 t = time.time()
 str(t)
'1375626035.26'
 repr(t)
'1375626035.260934'

I don't know anywhere that those behaviors are guaranteed, however.  If 
you want to make sure you print a float with 6 digits after the decimal, 
you should use %f, not %s:

 '%.6f' % t
'1375626035.260934'

Of course, if the underlying system call that time.time() invokes 
returns less precision than microseconds, some of those 6 digits may 
always be zero.  Or worse, garbage.

Taking a step back, you're probably better off using datetimes.  You'll 
get all this conversion nonsense for free:

 print datetime.datetime.utcnow()
2013-08-04 14:33:09.255096

When I write an operating system, I'm going to have it keep time in 
units of YiTp (Yobi Plank times).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can someone suggest better resources for learning sqlite3? I wanted to use the Python library but I don't know sql.

2013-08-04 Thread inq1ltd
On Saturday, August 03, 2013 10:57:32 AM Aseem Bansal wrote:
 I was writing a Python script for getting the user stats of a
 website(Specifically codereview.stackexchange). I wanted to store the 
stats
 in a database. I found Python3's sqlite3 library. I found that I needed sql
 commands for using it.
 
 I have tried sql.learncodethehardway but it isn't complete yet. I tired
 looking on stackoverflow's  sql tag also but nothing much there. Can
 someone suggest me better resources for learning sql/sqlite3?


Go to:
sqlite-us...@sqlite.org
and join.

Ask any question, you will get an answer.
 
Print out the manual.  For someone that is not 
familiar with Relational DB programming it
may look like a newspaper from 
another planet, but you should have it.

You mentioned creating a database for stats. Learn 
how to create a table, and populate it. that is basic.
Ask how to on the users help site, then compare the 
method sent to you to the manual.  You need to know 
how the answer relates to the manual.

The sqlite manual is in the standard format that is the 
accepted world wide.  Once you can understand 
the manual format you can work your way through a 
lot of what you want to do. 

jimonlinux
inqvista.com







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


Re: Python script help

2013-08-04 Thread cool1574
I understand I did not ask the question correctly, but is there any chance you 
can help me put together this code? I know that you all do this for fun and 
enjoy it and that is why I asked you guys instead of asking some one who will 
charge me for a very simple line of code.
I would appreciate it, Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


In pyqt, some signals seems not work well

2013-08-04 Thread Jacknaruto
Hi, Guys!
I created a thread class based QThread, and defined some signals to update UI 
through main thread.
the UI used a stackedWidget,someone page named 'progressPage' have a 
progressBar and a Label, the next page named 'resultsPage' shows results(some 
Labels).
When the window showed progressPage, my code that updates progressBar was well, 
but the updating resultsPage's labels signals seems ignored by main thread.(I 
guess, because I added some prints in the slot, it wasn't printed)
the code like this:class worker(QtCore.QThread):sig_jump_finish_page = 
QtCore.pyqtSignal()sig_set_label_text = QtCore.pyqtSignal(str,  str)
sig_set_progress_value = QtCore.pyqtSignal(int)
for dirpath,  dirnames, filenames  in os.walk(self.root):for 
filename in filenames:self.sig_set_label_text.emit('current', 
self.current())   # work well# so something
#self.dialog.set_found(str(self.found()))  # work well
#self.dialog.set_all(str(self.total()))  # work well
self.sig_set_label_text.emit('found',  str(self.found()))  # :(
self.sig_set_label_text.emit('all',  str(self.total()))   # :(
self.sig_jump_finish_page.emit()
So I have to update UI directly in the thread(comments Line 11-12 shows), it 
looks work well.
I found the difference between line 8 and line 13-14 is line 8 manipulates 
current page -progressPage, line 13-14 manipulates next page -resultsPage.
Is some wrongs in there?


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


RE: Logging help

2013-08-04 Thread Joseph L. Casale
Oh hai - as I was reading the documentation, look what I found:

http://docs.python.org/2/library/logging.html#filter

Methinks that should do exactly what you want.

Hi Wayne,
I was too hasty when I looked at filters as I didn't think they could do
what I wanted. Turns out a logging object sent the filter method will
an exc_info attribute in my case.

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


Re: Python script help

2013-08-04 Thread Chris Angelico
On Sun, Aug 4, 2013 at 4:57 PM,  cool1...@gmail.com wrote:
 I understand I did not ask the question correctly, but is there any chance 
 you can help me put together this code? I know that you all do this for fun 
 and enjoy it and that is why I asked you guys instead of asking some one who 
 will charge me for a very simple line of code.
 I would appreciate it, Thank you.

There are a million and one projects out there that I could do for
fun. Why should I do yours rather than one of theirs? The key is to
make your problem look more fun, or more useful, than the others. At
the moment, it looks fairly un-fun (just recreating wget with less
features), and not particularly useful (you could just use wget). So
at the moment, I don't feel inclined to put in several hours of unpaid
work for you.

I'll give you a few examples of things I *have* put hours of unpaid
work into, over the past few weeks:

* The Savoynet Performing Group production of The Yeomen of the Guard.
It's fun because the music's great and I'm working with awesome
people. (Also because the director has come up with an interpretation
of the finale that works better than any I've yet seen.) The lead
soprano is very close to going insane, the tragic comic sends a shiver
up my spine with the way he says Elsie, and we have chocolate at
rehearsal (which I provide at my own expense). Fun and useful.

* The professional company performing Pirates of Penzance and Iolanthe
needs help moving costumes in and out. Again, useful, and working with
the best people. When the organizers of an international festival say
you're invaluable, that's pretty high praise.

* The Gilbert  Sullivan Society back home needs someone to manage its
domain, web hosting, internal Mailman list, etc, etc, etc. Most of it
is fairly mundane and unexciting, but it's useful.

* Gypsum is my designated successor to my somewhat popular MUD client
RosMud, achieving many of the things that I can't do with RosMud. As a
gamer, I like my game clients. Very fun and very useful.

* Related to the above, digging through the uncharted waters of mixed
metaphors and the Pike programming language, discovering language bugs
that probably nobody had ever run into before; and then submitting
patches and, again, seeing the approval and appreciation from people I
respect highly.

* Reading Alice in Wonderland to my eleven-year-old sister who'd never
heard it before. (Also to the rest of the family, who frequently 'just
happened' to hang around as I was reading.)

* Telling people about the Alice: Otherlands Kickstarter campaign [1],
which I'd really like to see succeed (if it reaches $250,000 within
the next few hours, the original voices of Alice and the Cheshire Cat
will be brought in!).

These are all projects that tie in with one of my interests or hobbies
(Gilbert and Sullivan, MUDding, and Alice in Wonderland). That gives
them a huge head-start in the fun and interesting categories.
You're trying to get me to donate my time and effort to your project;
to do that, you have to make your project look as interesting as one
of those. Okay, maybe not quite; each of the above has had MANY dev
hours donated to it, and you're just looking for maybe 1-2 hours. But
still, that's worth maybe a hundred dollars, so think of your request
as soliciting a donation of that amount. How are you going to pitch
that?

By the way, I am right now donating time towards a meta-cause: your
ability to handle yourself on an internet mailing list. I consider
that cause to be *extremely* useful, because it empowers the world and
you in ways that will make life easier for everyone, most notably
people on this list who I respect quite highly. So I'm happy to donate
ten or fifteen minutes to explaining exactly what it takes to get
something done, because - unless I've completely misread you - you,
and the whole world, will benefit that many times over.

[1] http://www.kickstarter.com/projects/spicyhorse/alice-otherlands

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


Re: Where to suggest improvements in the official Python documentation?

2013-08-04 Thread Aseem Bansal
@ Terry Jan Reedy

If there is an issue in place for improving the lambda forms then that's good. 
I wanted a link about functional programming because it is mentioned as if it 
were a household word.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP8 revised: max line lengths

2013-08-04 Thread Chris Angelico
On Sun, Aug 4, 2013 at 3:07 PM, Roy Smith r...@panix.com wrote:
 In article d2e561f1-f5ba-4242-941d-6989abd1a...@googlegroups.com,
  wxjmfa...@gmail.com wrote:

 I have always found, computer scientists are funny scientists.

 I have always found that sciences which contain the word science in
 their name tend to not be very scientific.

 Biology, Chemistry, Physics, those are real sciences.  Computer Science,
 Social Science, Political Science, not so much.

Right. We use the scientific method only in our worst work, like
poking at a black-box system to try to reverse compile it. Our work
generally involves examining a problem and figuring out which set of
tools will best solve it, which is more of an engineering thing.
(Build a bridge. Your chasm is X meters across, your bridge must
support Y kg of vehicles traversing it, the terrain is unsuited to
pylons, and you must not exceed Z meters of height above the road
surface.) And programmers, like engineers, have to deal with the
possibility (or certainty) of idiots using their products. This is not
a pure science by any means.

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


Re: PEP8 revised: max line lengths

2013-08-04 Thread Roy Smith
In article mailman.186.1375639877.1251.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 programmers, like engineers, have to deal with the
 possibility (or certainty) of idiots using their products.

As a programmer, I'm OK with the idea that idiots are using my programs.  
What bothers me more is when, as a user of a program, I have to deal 
with the fact that idiots wrote it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: In pyqt, some signals seems not work well

2013-08-04 Thread Vincent Vande Vyvre

Le 04/08/2013 18:06, Jacknaruto a écrit :

Hi, Guys!

I created a thread class based QThread, and defined some signals to 
update UI through main thread.


the UI used a stackedWidget,someone page named 'progressPage' have a 
progressBar and a Label, the next page named 'resultsPage' shows 
results(some Labels).


When the window showed progressPage, my code that updates progressBar 
was well, but the updating resultsPage's labels signals seems ignored 
by main thread.(I guess, because I added some prints in the slot, it 
wasn't printed)


the code like this:

 1. class worker(QtCore.QThread):
 2. sig_jump_finish_page = QtCore.pyqtSignal()
 3. sig_set_label_text = QtCore.pyqtSignal(str, str)
 4. sig_set_progress_value = QtCore.pyqtSignal(int)
5.

 6. for dirpath, dirnames, filenames in os.walk(self.root):
 7. for filename in filenames:
 8. self.sig_set_label_text.emit('current', self.current()) # work well
 9. # so something
10.

11. #self.dialog.set_found(str(self.found())) # work well
12. #self.dialog.set_all(str(self.total())) # work well
13. self.sig_set_label_text.emit('found', str(self.found())) # :(
14. self.sig_set_label_text.emit('all', str(self.total())) # :(
15.

16. self.sig_jump_finish_page.emit()


So I have to update UI directly in the thread(comments Line 11-12 
shows), it looks work well.


I found the difference between line 8 and line 13-14 is line 8 
manipulates current page -progressPage, line 13-14 manipulates next 
page -resultsPage.


Is some wrongs in there?






Have a look at my comments:

class worker(QtCore.QThread):
sig_jump_finish_page = QtCore.pyqtSignal()
sig_set_label_text = QtCore.pyqtSignal(str, str)
sig_set_progress_value = QtCore.pyqtSignal(int)

for dirpath, dirnames, filenames in os.walk(self.root): # What is 'self' 
here ?

for filename in filenames:
self.sig_set_label_text.emit('current', self.current()) # where is 
'current' ?

# so something

#self.dialog.set_found(str(self.found())) # What is self, and dialog, 
and found ?

#self.dialog.set_all(str(self.total())) # ...
self.sig_set_label_text.emit('found', str(self.found())) # again ?
self.sig_set_label_text.emit('all', str(self.total())) # etc

self.sig_jump_finish_page.emit()

--
Vincent V.V.
Oqapy https://launchpad.net/oqapy . Qarte 
https://launchpad.net/qarte . PaQager https://launchpad.net/paqager

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


stupid simple scope issue

2013-08-04 Thread JohnD
After 5 year of no Python programming I decided that I needed to brush
up my skills. Started writing on a reasonably complicated problem.
Unfortunately my basic Python skill are gone.

I present the bare-bore problem. This code does not produce the expected
result: can anyone tell me why? As you will guess, I want the first
three lines of output identical to the second three lines...

Can anyone point out the solution? Thanks!

#~/usr/bin/python
import random
class boys:
state={}
class boy:
state={
'name':'',
'age':''
}
names=['a','b','c']

def add_names():
global boys
for n in names:
boy.state['name']=n
boy.state['age']=random.randint(1, 1000)
boys.state[n]=boy.state
print boy.state['name'], boy.state['age']

add_names()

for n in boys.state:
boy.state=boys.state[n]
print boy.state['name'], boy.state['age']


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


Re: PEP8 revised: max line lengths

2013-08-04 Thread Chris Angelico
On Sun, Aug 4, 2013 at 7:18 PM, Roy Smith r...@panix.com wrote:
 In article mailman.186.1375639877.1251.python-l...@python.org,
  Chris Angelico ros...@gmail.com wrote:

 programmers, like engineers, have to deal with the
 possibility (or certainty) of idiots using their products.

 As a programmer, I'm OK with the idea that idiots are using my programs.
 What bothers me more is when, as a user of a program, I have to deal
 with the fact that idiots wrote it.

Heh. Yeah. Too true.

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


Re: Where to suggest improvements in the official Python documentation?

2013-08-04 Thread Joel Goldstick
On Sun, Aug 4, 2013 at 12:30 PM, Aseem Bansal asmbans...@gmail.com wrote:
 @ Terry Jan Reedy

 If there is an issue in place for improving the lambda forms then that's 
 good. I wanted a link about functional programming because it is mentioned as 
 if it were a household word.

It depends on your household I suppose!

Have you tried google?

I am having a hard time understanding what your specific question is.
Do you have one?
 --
 http://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stupid simple scope issue

2013-08-04 Thread Chris Angelico
On Sun, Aug 4, 2013 at 7:20 PM, JohnD j...@nowhere.com wrote:
 #~/usr/bin/python

If this is meant to be a Unix-style shebang, the second character
needs to be ! not ~. This has no effect on Python though.

 import random
 class boys:
 state={}
 class boy:
 state={
 'name':'',
 'age':''
 }

At no time do you actually instantiate any objects from these types.
In fact, you may as well drop the class blocks and the .state usage
and simply use:

boys = {}
boy = {'name':'', 'age':''}

as this will achieve the exact same thing.

 def add_names():
 global boys

The global declaration is needed only if you assign to the name, eg
boys = ... - it's superfluous here.

 for n in names:
 boy.state['name']=n
 boy.state['age']=random.randint(1, 1000)
 boys.state[n]=boy.state
 print boy.state['name'], boy.state['age']

Each time you do this, you're modifying the same 'boy' mapping, then
putting another reference to it in 'boys'. I think possibly what you
want here is to construct a new boy() instance for each one.

 add_names()

 for n in boys.state:
 boy.state=boys.state[n]
 print boy.state['name'], boy.state['age']

I'd look at doing it more like this:

class boy:
def __init__(self,name,age):
self.name=name; self.age=age
boys = {}

def add_name(n):
b = boy(n,random.randint(1, 1000))
boys[n] = b
print b.name, b.age

for n in 'a','b','c':
add_name(n)

for n,b in boys.items():
print b.name, b.age


Or possibly even dispense with the boy class altogether and simply use
a dictionary - or simply map a name to an age, since (as you can see
in the final loop) it's easy enough to iterate over the dictionary.
(Note that the code above is untested and probably has an egregious
bug in it somewhere.)

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


Re: stupid simple scope issue

2013-08-04 Thread JohnD
On 2013-08-04, Chris Angelico ros...@gmail.com wrote:
[...]
Thank you very much. The dust is slowly starting to move.
The code posted is nothing like the real thing, but I tried
to capture the essence. 

From your commants I think I see my mistake.

Thank you very much for your reply!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: stupid simple scope issue

2013-08-04 Thread Chris Angelico
On Sun, Aug 4, 2013 at 8:21 PM, JohnD j...@nowhere.com wrote:
 On 2013-08-04, Chris Angelico ros...@gmail.com wrote:
 [...]
 Thank you very much. The dust is slowly starting to move.
 The code posted is nothing like the real thing, but I tried
 to capture the essence.

 From your commants I think I see my mistake.

 Thank you very much for your reply!

No probs!

Python does have a slightly odd (compared to other languages)
interpretation of variable assignments (name bindings, really)
inside a class block. Trips up a lot of people.

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


Bug? ( () == [] ) != ( ().__eq__([]) )

2013-08-04 Thread Markus Rother

Hello,

The following behaviour seen in 3.2 seems very strange to me:

As expected:
 () == []
False

However:
 ().__eq__([])
NotImplemented
 [].__eq__(())
NotImplemented

And:
 bool(NotImplemented)
True

Hence:
 bool(().__eq__([]))
True
 ( () == [] ) != ( ().__eq__([]) )
True

How/why can this be intended?

Thanks, everybody.

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


Re: Python script help

2013-08-04 Thread Michael Torrie
On 08/02/2013 03:46 AM, cool1...@gmail.com wrote:
 I do know some Python programming, I just dont know enough to put
 together the various scripts I need...I would really really
 appreciate if some one can help me with that...

Seems like your first task, then, is to become proficient at python so
that you can read the scripts you find and understand how they work so
that you can then take that as inspiration for your own project.  We're
happy to answer questions about python programming in general.

Good luck. Python is a really fun language and if you read the docs and
tutorials, and start actually messing around with code (there are lots
of examples of using urllib2 out there, and also parsing libraries),
you'll make good progress.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bug? ( () == [] ) != ( ().__eq__([]) )

2013-08-04 Thread MRAB

On 04/08/2013 23:35, Markus Rother wrote:

Hello,

The following behaviour seen in 3.2 seems very strange to me:

As expected:
   () == []
False

However:
   ().__eq__([])
NotImplemented
   [].__eq__(())
NotImplemented

And:
   bool(NotImplemented)
True

Hence:
   bool(().__eq__([]))
True
   ( () == [] ) != ( ().__eq__([]) )
True

How/why can this be intended?


The docs say:

NotImplemented
This type has a single value. There is a single object with this value. 
This object is accessed through the built-in name NotImplemented. 
Numeric methods and rich comparison methods may return this value if 
they do not implement the operation for the operands provided. (The 
interpreter will then try the reflected operation, or some other 
fallback, depending on the operator.) Its truth value is true.



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


Re: Bug? ( () == [] ) != ( ().__eq__([]) )

2013-08-04 Thread Chris Angelico
On Sun, Aug 4, 2013 at 11:35 PM, Markus Rother pyt...@markusrother.de wrote:
 Hello,

 The following behaviour seen in 3.2 seems very strange to me:

 As expected:
 () == []
 False

 However:
 ().__eq__([])
 NotImplemented
 [].__eq__(())
 NotImplemented

You don't normally want to be calling dunder methods directly. The
reasoning behind this behaviour goes back to a few things, including a
way to handle 1 == Foo() where Foo is a custom type that implements
__eq__; obviously the integer 1 won't know whether it's equal to a Foo
instance or not, so it has to defer to the second operand to get a
result. This deferral is done by returning NotImplemented, which is an
object, and so is true by default. I don't see any particular reason
for it to be false, as you shouldn't normally be using it; it's more
like a null state, it means I don't know if we're equal or not. If
neither side knows whether they're equal, then they're presumed to be
unequal, but you can't determine that from a single call to __eq__.

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


Re: Python script help

2013-08-04 Thread Jake Angulo
On Mon, Aug 5, 2013 at 8:58 AM, Michael Torrie torr...@gmail.com wrote:

 On 08/02/2013 03:46 AM, cool1...@gmail.com wrote:
  I do know some Python programming, I just dont know enough to put
  together the various scripts I need...I would really really
  appreciate if some one can help me with that...


Hi Cool,

Unfortunately you really gotta know enough Python to put things together,
so if you have time - learn a little more python, and then you can choose
any of these 2 tools to do the job:
http://doc.scrapy.org/en/latest/intro/tutorial.html
http://www.gregreda.com/2013/03/03/web-scraping-101-with-python/

In fact i agree you dont even need python.  Even Bash / shell script with
wget can do this.

However if you dont have the time or dont want to exert the req'd effort,
unfortunately this list is not for giving free code.
I suggest you hire somebody at odesk.com or elance.com - you'd be amazed
how low people there charge for python web scraping.

Good luck!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: In pyqt, some signals seems not work well

2013-08-04 Thread Jack

On 2013/8/5 2:20, Vincent Vande Vyvre wrote:

Le 04/08/2013 18:06, Jacknaruto a écrit :

Hi, Guys!

I created a thread class based QThread, and defined some signals to 
update UI through main thread.


the UI used a stackedWidget,someone page named 'progressPage' have a 
progressBar and a Label, the next page named 'resultsPage' shows 
results(some Labels).


When the window showed progressPage, my code that updates progressBar 
was well, but the updating resultsPage's labels signals seems ignored 
by main thread.(I guess, because I added some prints in the slot, it 
wasn't printed)


the code like this:

 1. class worker(QtCore.QThread):
 2. sig_jump_finish_page = QtCore.pyqtSignal()
 3. sig_set_label_text = QtCore.pyqtSignal(str, str)
 4. sig_set_progress_value = QtCore.pyqtSignal(int)
5.

 6. for dirpath, dirnames, filenames in os.walk(self.root):
 7. for filename in filenames:
 8. self.sig_set_label_text.emit('current', self.current()) # work well
 9. # so something
10.

11. #self.dialog.set_found(str(self.found())) # work well
12. #self.dialog.set_all(str(self.total())) # work well
13. self.sig_set_label_text.emit('found', str(self.found())) # :(
14. self.sig_set_label_text.emit('all', str(self.total())) # :(
15.

16. self.sig_jump_finish_page.emit()


So I have to update UI directly in the thread(comments Line 11-12 
shows), it looks work well.


I found the difference between line 8 and line 13-14 is line 8 
manipulates current page -progressPage, line 13-14 manipulates next 
page -resultsPage.


Is some wrongs in there?






Have a look at my comments:

class worker(QtCore.QThread):
sig_jump_finish_page = QtCore.pyqtSignal()
sig_set_label_text = QtCore.pyqtSignal(str, str)
sig_set_progress_value = QtCore.pyqtSignal(int)


I'm sorry.
In run() function the code below
for dirpath, dirnames, filenames in os.walk(self.root): # What is 
'self' here ?
self is current object, isn't it? self.root is a path which the 
user will specify.

for filename in filenames:
self.sig_set_label_text.emit('current', self.current()) # where is 
'current' ?

# so something
self.current() is a getter, it just returns a member that shows the 
path of the current work.


#self.dialog.set_found(str(self.found())) # What is self, and dialog, 
and found ?

the main thread is a dialog object.
self.dialog was assigned the dialog object in the __init__ of 
worker class.
self.found() is a getter also, it returns the number of meeting the 
conditions. self.total() means like this.

#self.dialog.set_all(str(self.total())) # ...
self.sig_set_label_text.emit('found', str(self.found())) # again ?
self.sig_set_label_text.emit('all', str(self.total())) # etc

self.sig_jump_finish_page.emit()


dialog.set_all() and so on just sets the widget's text.

My English is poor, I hopeyou will excuse me.

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


Re: [argparse] mutually exclusive group with 2 sets of options

2013-08-04 Thread Francois Lafont
Hello,

Up. ;-)

Le 04/08/2013 04:10, Francois Lafont a écrit :

 Is it possible with argparse to have this syntax for a script?
 
 my-script (-a -b VALUE-B | -c -d VALUE-D)
 
 I would like to do this with the argparse module.
 
 Thanks in advance.

I have found this post:
https://groups.google.com/forum/#!searchin/argparse-users/exclusive/argparse-users/-o6GOwhCjbQ/m-PfL4OxLAIJ

It was in 2011 and at that time, it was impossible to have the syntax above. I 
have the impression that it's impossible now yet. Am I wrong?

If it's impossible yet, I could try a hack. With some checks, I think I could 
have the (-a -b VALUE-B | -c -d VALUE-D) behavior but I would like this 
syntax appear in the help output too and I have no idea to do it.

-- 
François Lafont
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [argparse] mutually exclusive group with 2 sets of options

2013-08-04 Thread Joshua Landau
On 5 August 2013 03:05, Francois Lafont francois.lafont@nospam.invalidwrote:

 Hello,

 Up. ;-)

 Le 04/08/2013 04:10, Francois Lafont a écrit :

  Is it possible with argparse to have this syntax for a script?
 
  my-script (-a -b VALUE-B | -c -d VALUE-D)
 
  I would like to do this with the argparse module.
 
  Thanks in advance.

 I have found this post:

 https://groups.google.com/forum/#!searchin/argparse-users/exclusive/argparse-users/-o6GOwhCjbQ/m-PfL4OxLAIJ

 It was in 2011 and at that time, it was impossible to have the syntax
 above. I have the impression that it's impossible now yet. Am I wrong?

 If it's impossible yet, I could try a hack. With some checks, I think I
 could have the (-a -b VALUE-B | -c -d VALUE-D) behavior but I would like
 this syntax appear in the help output too and I have no idea to do it.


If possible you could try docopt. That should be able to do it quite easily.

You could write literally:

My-Script

Usage:
  my-script (-a -b VALUE-B | -c -d VALUE-D)

Options:
  -b VALUE-B  Description
  -d VALUE-D  Description

as the grammar, but:

My-Script

Usage:
  my-script -a -b VALUE-B
  my-script -c -d VALUE-D

Options:
  -b VALUE-B  Description
  -d VALUE-D  Description

would be preferred.
-- 
http://mail.python.org/mailman/listinfo/python-list


Hangman question

2013-08-04 Thread eschneider92
I'm  on chapter 9 of this guide to python: 
http://inventwithpython.com/chapter9.html but I don't quite understand why 
line 79 is what it is (blanks = blanks[:i] + secretWord[i] + blanks[i+1:]). I 
particularly don't get the [i+1:] part. Any additional information and help 
would be greatly appreciated!
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue8860] Rounding in timedelta constructor is inconsistent with that in timedelta arithmetics

2013-08-04 Thread Mark Dickinson

Mark Dickinson added the comment:

Alexander:  applying this is fine by me.  As a user-visible change, yes, I 
think it should have a Misc/NEWS entry.  (It's too small a change to be worth 
mentioning in the 'whatsnew' documents though.)

--

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



[issue18642] enhancement for operator 'assert'

2013-08-04 Thread Mark Dickinson

Mark Dickinson added the comment:

Okay, I'm closing this for now.  Al Korgun and mrDoctorWho0 .: if you think 
this idea deserves wider discussion, you should feel free to bring it up again 
on the python-ideas mailing list;  that's a better forum to discuss these sorts 
of language changes anyway (too few developers will look at any particular bug 
on the bug tracker; many more read python-ideas).  It seems unlikely to me that 
the idea would receive widespread acceptance, but I may well be wrong.

--
resolution:  - rejected
status: open - closed

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



[issue18264] enum.IntEnum is not compatible with JSON serialisation

2013-08-04 Thread Ethan Furman

Ethan Furman added the comment:

I don't understand.

Type checks are already performed throughout the code (int, float, True, False, 
NaN, Inf, etc.).

What will opereator.index buy us?

--

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



[issue18570] OverflowError in division: wrong message

2013-08-04 Thread Mark Dickinson

Mark Dickinson added the comment:

 With that fixed, I am inclined to close this.

Agreed.  I'll try to find some time for a PEP at some point in the next few 
weeks.

 I had thought of a set-mode function (method), but anticipate objection
 to such modal action-at-distance behavior.

Yes;  I'm not a big fan of global state[*] either in general, but there aren't 
many other good options:  specifying the mode to each operation individually 
would be painful and prevent natural use of infix operators, generally making 
code more unreadable.  There *would* need to be some kind of set-mode function 
(or perhaps writable sys module attribute) as you suggest, but the context 
manager could be promoted as the recommended way to change the state in a 
manner that's reasonably safe and explicit.


[*] We'd want it to be thread-local rather than global, of course.

--

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



[issue18570] OverflowError in division: wrong message

2013-08-04 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
resolution:  - postponed
status: open - closed

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



[issue11033] ElementTree.fromstring doesn't work with Unicode

2013-08-04 Thread Brendan O'Connor

Brendan O'Connor added the comment:

Sure, go ahead and close it.  I was just trying to be helpful and report a bug 
in the Python standard library.  I don't use Python 3.3 so cannot test it.

--
nosy: +Brendan.OConnor

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



[issue18264] enum.IntEnum is not compatible with JSON serialisation

2013-08-04 Thread Nick Coghlan

Nick Coghlan added the comment:

The two isinstance checks that bother me are the ones for int and float. 
However, given that the JSON serialiser *already* includes those explicit 
checks, I now think it makes sense to just do the minimal fix of coercing 
subclasses to the base type for both of those cases, especially since such a 
change should be able to be ported to simplejson as well.

Anything more elaborate (including making JSON explicitly enum aware, or else 
offering a new encoder that supports singledispatch) should be handled in a 
separate issue.

--

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



[issue18151] Idlelib: update to with open ... except OSError (in 2.7, leave IOError)

2013-08-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch which replace the open ... close idiom to the with open 
idiom in IDLE.

--
stage: commit review - patch review
Added file: http://bugs.python.org/file31144/idle_with_open.patch

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



[issue18151] Idlelib: update to with open ... except OSError (in 2.7, leave IOError)

2013-08-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch which replace the open ... close idiom to the with open 
idiom in IDLE.

--
Added file: http://bugs.python.org/file31145/idle_with_open.patch

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



[issue14012] Misc tarfile fixes

2013-08-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is updated for 3.4 patch.

--
Added file: http://bugs.python.org/file31146/tarfile-misc-bugs-3.4.diff

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



[issue8865] select.poll is not thread safe

2013-08-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Gregory, could you commit the patch or allow me to do this?

--

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



[issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

2013-08-04 Thread Mark Dickinson

Mark Dickinson added the comment:

See the related python-dev discussion started by Mark Shannon here:

http://mail.python.org/pipermail/python-dev/2013-March/125022.html

and continuing well into April here:

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

The consensus that emerged from that thread seems to be that calls to 
operator.index and to int() should always return something of exact type int.

The attached patch:

- Raises TypeError for implicit calls to nb_int that fail to return something 
of exact type int.  (Results of direct calls to __int__ are not checked.)

- Ensures that *all* conversions from a non-int to an int via nb_int make use 
of the nb_int slot, even for int subclasses.  Prior to this patch, some of the 
PyLong_As... functions would bypass __int__ for int subclasses.

- Adds a new private _PyLong_FromNbInt function to Objects/longobject.c, so 
that we have a single place for performing these conversions and making type 
checks, and refactors existing uses of the nb_int slot to go via this function.

- Makes corresponding changes for nb_index, which should address the original 
bug report.

I guess this may be too dangerous a change for Python 3.4.  In that case, I 
propose raising warnings instead of TypeErrors for Python 3.4 and turning those 
into TypeErrors in Python 3.5.

One other question:  should direct calls to __int__ and __index__ also have 
their return values type-checked?  That doesn't seem to happen at the moment 
for other magic methods (see below), so it would seem consistent to only do the 
type checking for interpreter-generated implicit calls to __int__ and 
__index__.  Nick: any opinion?

 class A:
... def __len__(self): return a string
... def __bool__(self): return another string
... 
 a = A()
 a.__len__()
'a string'
 a.__bool__()
'another string'
 len(a)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: 'str' object cannot be interpreted as an integer
 bool(a)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: __bool__ should return bool, returned str

--
assignee: docs@python - mark.dickinson
components: +Interpreter Core -Documentation
keywords: +patch
nosy: +ncoghlan
Added file: http://bugs.python.org/file31147/issue17576.patch

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



[issue18651] test failures on KFreeBSD

2013-08-04 Thread Matthias Klose

New submission from Matthias Klose:

Some tests fail on KFreeBSD, attaching a first patch from Petr Salinger. 

see http://bugs.debian.org/708653 for further issues.

Ronald, could you check if that this works for OSX too?

--
components: Tests
files: kfreebsd.diff
keywords: patch
messages: 194336
nosy: doko, ronaldoussoren
priority: normal
severity: normal
status: open
title: test failures on KFreeBSD
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file31148/kfreebsd.diff

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



[issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

2013-08-04 Thread Mark Dickinson

Mark Dickinson added the comment:

New patch that replaces the TypeErrors with warnings and fixes a refleak in the 
original patch.

--
Added file: http://bugs.python.org/file31149/issue17576_v2.patch

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



[issue18652] Add a “first” function to the stdlib

2013-08-04 Thread Hynek Schlawack

New submission from Hynek Schlawack:

Let met try to get you sold on adding the “first” function I released on PyPI 
roughly a year ago:

https://github.com/hynek/first

It’s a very nice complement to functions like `any()` or itertools. I consists 
effectively of 9 lines of code but it proved extremely handy in production.

***

It returns the first true value from an iterable or a default:

 first([0, None, False, [], (), 42])
42

 first([0, None, False, [], ()], default=42)
42

Additionally it also allows for a key function:

 first([1, 1, 3, 4, 5], key=lambda x: x % 2 == 0)
4

***

First happens to be especially useful together with the re module:

import re

from first import first


re1 = re.compile('b(.*)')
re2 = re.compile('a(.*)')

m = first(regexp.match('abc') for regexp in [re1, re2])
if not m:
   print('no match!')
elif m.re is re1:
   print('re1', m.group(1))
elif m.re is re2:
   print('re2', m.group(1))


All the knee-jerk alternatives to it have some shortcomings:

next(itertools.ifilter(None, (regexp.match('abc') for regexp in [re1, re2])), 
None)
next((regexp.match('abc') for regexp in [re1, re2] if regexp.match('abc')), 
None)

None of them is Pythonic and the second one even has to call match() twice, 
which is *not* a cheap method to call.

Here the first version for comparison again:

first(regexp.match('abc') for regexp in [re1, re2])

It doesn’t even exhaust the iterator if not necessary.

***

I don’t cling to neither the name or the exact function signature (although it 
got polished with the help of several people, two of them core developers).  I 
also don’t really care whether it gets added along of any() or put into 
itertools.  I just know that I and several other people would appreciate to 
have such a handy function in the stdlib – I even got an e-mail from OpenStack 
folks asking when it will be added because they would like to use it and 
there’s even a debian package by now: 
http://packages.debian.org/unstable/python-first

There’s also this question on StackOverflow: 
http://stackoverflow.com/questions/1077307/why-is-there-no-firstiterable-built-in-function-in-python
 which is nice but doesn’t fix the subtleties like when there is no true value 
etc which makes it useless for production code and one has to write boilerplate 
code every single time.

It was even one of five Python packages Lukasz Langa deemed worthy to be 
highlighted in his PyCon 2013 lightning talk: 
http://youtu.be/1vui-LupKJI?t=20m40s

FWIW, SQL has a similar function called COALESCE ( 
https://en.wikipedia.org/wiki/Null_(SQL)#COALESCE ) which only handles NULL 
though.

***

I’ll happily respond to any questions or concerns that may arise and supply a 
patch as soon as we agree on a place to add it.

--
assignee: hynek
components: Library (Lib)
messages: 194338
nosy: hynek, lukasz.langa, ncoghlan, rhettinger
priority: normal
severity: normal
status: open
title: Add a “first” function to the stdlib
type: enhancement
versions: Python 3.4

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



[issue18647] re.error: nothing to repeat

2013-08-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e2ba4592ce3a by Serhiy Storchaka in branch '2.7':
Issue #18647: Temporary disable the nothing to repeat check to make buildbots 
happy.
http://hg.python.org/cpython/rev/e2ba4592ce3a

--

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



[issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding

2013-08-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch for 2.7.

--
Added file: http://bugs.python.org/file31150/expat_buffer_overflow-2.7.patch

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



[issue18652] Add a “first” function to the stdlib

2013-08-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The function name looks a little misleading. I expected first([0, None, False, 
[], (), 42]) returns 0.

--
nosy: +serhiy.storchaka

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



[issue18201] distutils write into symlinks instead of replacing them

2013-08-04 Thread Michał Górny

Michał Górny added the comment:

Oh, sorry. I've looked throughout the code again and it seems that distutils is 
doing the right thing. It's setuptools/distribute that is broken.

--
resolution:  - invalid
status: open - closed

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



[issue18652] Add a “first” function to the stdlib

2013-08-04 Thread Nick Coghlan

Nick Coghlan added the comment:

It's a direct counterpart to any() and all() - first([0, [], ()]) is None for 
the same reason that any([0, [], ()]) and all([0, [], ()]) are both False.

If first returned the actual first item in the iterable (regardless of truth 
value), then it would just be next under a different name, which would be 
rather pointless.

That said, if first is deemed too ambiguous, then I believe filterednext 
would be a reasonable more explicit name:

 filterednext([0, None, False, [], (), 42])
42

 filterednext([0, None, False, [], ()], default=42)
42

 filterednext([1, 1, 3, 4, 5], key=lambda x: x % 2 == 0)
4

 m = filterednext(regexp.match('abc') for regexp in [re1, re2])

I also believe itertools would be a more appropriate initial home than the 
builtins.

--

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



[issue13238] Add shell command helpers to subprocess module

2013-08-04 Thread Piotr Dobrogost

Changes by Piotr Dobrogost p...@bugs.python.dobrogost.net:


--
nosy: +piotr.dobrogost

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



[issue17684] Skip tests in test_socket like testFDPassSeparate on OS X

2013-08-04 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Charles-Francois: why did you commit this to default only, and not to 3.3?
(see also issue18651)

--
nosy: +loewis

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



[issue18651] test failures on KFreeBSD

2013-08-04 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Note that 3.4 will need a different patch, due to issue17684.

--
nosy: +loewis

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



[issue18652] Add a “first” function to the stdlib

2013-08-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

In this case it would be pointless too. It is just

next(filter(key, iterable), default)

Are you need a special function for combination of two builtins?

--

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



[issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

2013-08-04 Thread Nick Coghlan

Nick Coghlan added the comment:

The deprecation warning version looks good to me.

Something I'll mention explicitly (regarding the PyCon discussions that Eric 
mentioned above), is that we unfortunately couldn't do something like this for 
the various concrete APIs with overly permissive subclass checks. For those 
APIs, calling them directly was often the *right* thing for simple subtypes 
implemented in C to use to call up to the parent implementation.

This case is different, as it's the *abstract* APIs that currently have the 
overly permissive checks.

--

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



[issue18652] Add a “first” function to the stdlib

2013-08-04 Thread Hynek Schlawack

Hynek Schlawack added the comment:

`filter()` exhausts the full iterator which is potentially very expensive – 
like in conduction with regular expressions.

--

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



[issue18652] Add a “first” function to the stdlib

2013-08-04 Thread Martin v . Löwis

Martin v. Löwis added the comment:

I also think it should go to itertools.

I also found the name first confusing, in particular since it means what 
Serhiy assumes in LISP, which might be familiar to people interested in 
functional list processing. Also, Ruby and Smalltalk use first in that sense.

To add to the bike shedding, I propose find_if (from LISP), coalesce (from 
SQL), or detect (from Smalltalk).

-1 on calling the filter function key=. How about pred= (like all other 
itertools predicates) or filter=?

--
nosy: +loewis

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



[issue18652] Add a “first” function to the stdlib

2013-08-04 Thread Nick Coghlan

Nick Coghlan added the comment:

Serhiy, Hynek covered the issue with the status quo in the original
proposal.The existing alternative are painful to try and decipher by
comparison with the named function:

filterednext([0, None, False, [], (), 42])
vs
next(filter(None, [0, None, False, [], (), 42]))

filterednext([0, None, False, [], ()], default=42)
vs
next(filter(None, [0, None, False, [], (), 42]), 42)

filterednext([1, 1, 3, 4, 5], key=lambda x: x % 2 == 0)
vs
next(filter(lambda x: x % 2 == 0, [1, 1, 3, 4, 5]))

m = filterednext(regexp.match('abc') for regexp in [re1, re2])
vs
m = next(filter(None, (regexp.match('abc') for regexp in [re1, re2])))

Hynek - the Python 3 filter is an iterator, so it works like the
itertools.ifilter version in Python 2.

--

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



[issue18652] Add a “first” function to the stdlib

2013-08-04 Thread Hynek Schlawack

Hynek Schlawack added the comment:

Ah ok sorry. Anyhow, it’s just a very common idiom that should be easy and 
readable.

As said, I’m not married to any names at all and would happily add a 
compatibility package to PyPI with the new names/parameters.

--

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



[issue18652] Add a “first” function to the stdlib

2013-08-04 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Nick: that the code is difficult to decipher is really the fault of functional 
programming, which is inherently difficult to decipher (since last function 
applied is written first).

Explicit iteration is easier to read. I would write Hynek's example as

for r in (re1, re2):
m = r.match('abc')
if not m:
print('No match)
elif r is re1:
print('re1', m.group(1))
elif r is re2:
print('re1', m.group(1))
break # always

This is only two additional lines, very Pythonic (IMO), and doesn't invoke 
match unnecessarily.

--

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



[issue18652] Add a “first” function to the stdlib

2013-08-04 Thread Nick Coghlan

Nick Coghlan added the comment:

Regarding the key parameter name, I believe this is closer to itertools.groupby 
(which uses key= as an optional argument, akin to min, max and sorted) than 
it is to filterfalse, dropwhile or takewhile (which use pred as the first 
positional argument)

The only use of pred in the optional key argument sense appears to be the 
quantify recipe.

+1 for itertools.coalesce, taking the name from SQL. It's designed to serve 
exactly the same purpose as COALESCE does there, doesn't risk confusion with 
next-like behaviour the way first does and hints strongly at the fact it is a 
reduction operation from an iterable to a single value.

--

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



[issue18652] Add a “first”-like function to the stdlib

2013-08-04 Thread Hynek Schlawack

Hynek Schlawack added the comment:

Martin, I don’t find the loop easier to read because you have to *remember* the 
`break` otherwise “weird stuff happens”.

Coalesce seems common enough, I would +1 on that too.

--
title: Add a “first” function to the stdlib - Add a “first”-like function to 
the stdlib

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



[issue18652] Add itertools.coalesce

2013-08-04 Thread Nick Coghlan

Nick Coghlan added the comment:

(Updated the issue title to reflect the currently proposed name and location 
for the functionality)

While I'm a fan of explicit iteration as well (inside every reduce is a loop 
trying to get out), I think the fact Martin's explicit loop is buggy (it will 
never match re2 as it always bails on the first iteration) helps make the case 
for coalesce. The correct explicit loop looks something like this:

for r in (re1, re2):
m = r.match('abc')
if m is None:
continue
if r is re1:
print('re1', m.group(1))
elif r is re2:
print('re1', m.group(1))
break # Matched something
else:
print('No match')

(Or the equivalent that indents the loop body further and avoids the continue 
statement)

The coalesce version has a definite advantage in not needing a loop else clause 
to handle the nothing matched case:

m = coalesce(regexp.match('abc') for regexp in [re1, re2])
if m is None:
print('no match!')
elif m.re is re1:
print('re1', m.group(1))
elif m.re is re2:
print('re2', m.group(1))

--
title: Add a “first”-like function to the stdlib - Add itertools.coalesce

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



[issue18652] Add itertools.coalesce

2013-08-04 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Simplicity is in the eye of the beholder, yet... you need to remember the break 
when *writing* the code, so the loop might be more difficult to write (but 
then, I need to remember/lookup the function name and parameters for 
coalesce)... when reading the code, the break is already there, and easy to 
notice. With Nick's remark, it's even more obvious that it is difficult to 
write :-)

If an unknown (to the reader) function is used, reading the code becomes 
actually difficult, since the reader either needs to guess what the function 
does, or look it up.

Note that I'm not objecting the addition of the function (I'm neutral), just 
the claim that there are no simple alternatives. I'm neutral because it falls 
under the not every two-line function needs to go into the standard library 
rule; but then, if it is really popular, it helps readability if it is in the 
library (rather than duplicated by users).

--

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



[issue1300] subprocess.list2cmdline doesn't do pipe symbols

2013-08-04 Thread Piotr Dobrogost

Piotr Dobrogost added the comment:

Maybe the solution is to make what I was trying to do easier without
fooling with the shell instead of playing the fool's game of trying to
improve the ability to deal with the shell so we can pass things
through it unnecessarily.

You are too harsh for yourself :) We should be able to make use of shell easily 
the same way it's possible in other languages like Perl or Ruby.

It sure would be nice on Windows to have an equivalent of
list2cmdline() that works for the shell.

I agree. See issue 13238 for a list of libraries which make is easier to use 
shell from Python.

--
nosy: +piotr.dobrogost

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



[issue18653] mingw-meta: build core modules

2013-08-04 Thread Roumen Petrov

New submission from Roumen Petrov:

split of issue3871 - this is meta issue only for part related to build core. 
Remark: build of interpreter core is in issue17605 .

Now split is:
- 01 issue13756 : Python make fail on cygwin
- 02 issue17219 : add current dir in library path if building python standard 
extensions
- 03 issue6672   : Add Mingw recognition to pyport.h to allow building 
extensions
- 04 issue18485 : configure for shared build
- 05 issue18486 : dynamic loading support
- 06 issue18487 : implement exec prefix
- 07 issue18495 : ignore main program for frozen scripts
- 08 issue18496 : setup exclude termios module
- 09 issue18497 : setup _multiprocessing module
- 10 issue18498 : setup select module
- 11 issue18499 : setup _ctypes module with system libffi
- 12 issue18500 : defect winsock2 and setup _socket module
- 13 issue18630 : exclude unix only modules
- 14 issue18631 : setup msvcrt and _winapi modules
- 15 issue18632 : build extensions with GCC
- 16 issue18633 : use Mingw32CCompiler as default compiler for mingw* build
- 17 issue18634 : find import library
- 18 issue18636 : setup _ssl module
- 19 issue18637 : export _PyNode_SizeOf as PyAPI for parser module
- 20 issue18638 : generalization of posix build in sysconfig.py
- 21 issue18639 : avoid circular dependency from time module during native 
build of extentions
- 22 issue18640 : generalization of posix build in distutils/sysconfig.py
- 23 issue18641 : customize site
- 24 after above patches user must regenerate configure script.

Hints:
a) at configure time define environment variable CPPFLAGS with minimum 
supported version like this   -DWINVER=0x501 -D_WIN32_WINNT=0x501  
-DMS_COREDLL=1, i.e XP is now minimum. MS_COREDLL is required for ctype module
b) at configure time define environment variable CCSHARED with minimum 
supported version like this: -DWINVER=0x501 -D_WIN32_WINNT=0x501. Remark use 
same values as CPPFLAGS
c) use --without-libm
d) use --enable-shared
e) use --with-system-ffi

--
components: Build, Cross-Build, Extension Modules
messages: 194358
nosy: rpetrov
priority: normal
severity: normal
status: open
title: mingw-meta: build core modules
type: enhancement
versions: Python 3.4

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



[issue18652] Add itertools.coalesce

2013-08-04 Thread Mark Dickinson

Mark Dickinson added the comment:

[Nick]
 Regarding the key parameter name, I believe this is closer to
 itertools.groupby ...

Isn't this mostly about the return type?  `pred` is an indication that a 
boolean is being returned (or that the return value will be interpreted in a 
boolean context), while `key` is used for more general transformations.  In 
that sense, `pred` makes more sense here.

--
nosy: +mark.dickinson

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



[issue18264] enum.IntEnum is not compatible with JSON serialisation

2013-08-04 Thread Eli Bendersky

Eli Bendersky added the comment:

I also think that exchanging the explicit type checks by __index__ merits more 
thought and is outside the scope of this local fix. The proposed patch does not 
add any new type checks, but acts within the bounds of code for which the type 
is already established.

--

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



[issue18652] Add itertools.coalesce

2013-08-04 Thread Nick Coghlan

Nick Coghlan added the comment:

Mark's rationale makes sense to me. I believe that would make the
latest version of the proposed API (in the itertools module):

def coalesce(iterable, default=None, pred=None):
...

--

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



[issue18624] Add alias for iso-8859-8-i which is the same as iso-8859-8

2013-08-04 Thread Dan Søndergaard

Dan Søndergaard added the comment:

Is it satisfactory to just add the -i and -e variants to ALIASES in charset.py? 
Or don't they qualify as Aliases for other commonly-used names for character 
sets?

--
nosy: +das

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



[issue18654] modernize mingwcygwin compiler classes

2013-08-04 Thread Roumen Petrov

New submission from Roumen Petrov:

Python mingw and cygwin compiler classes tests for outdated features. Also 
python code set some flags like zero optimization level and etc. that prevent 
users to build optimized python or even worse build to fail.

This issue is part of split of issue3871 with clean-up and enhancements:
- archive contain set of 10 patches - remove of outdated (15 years old ) 
features one by one.
- enhance unix compiler customization with mingw and cygwin compilers

--
assignee: eric.araujo
components: Build, Cross-Build, Distutils
files: modernize-mingw+cygwin-compiler-class.tar.gz
messages: 194363
nosy: eric.araujo, rpetrov, tarek
priority: normal
severity: normal
status: open
title: modernize mingwcygwin compiler classes
type: enhancement
versions: Python 3.4
Added file: 
http://bugs.python.org/file31151/modernize-mingw+cygwin-compiler-class.tar.gz

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



[issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding

2013-08-04 Thread Eli Bendersky

Eli Bendersky added the comment:

Thanks, Serhiy.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding

2013-08-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b3efc140d8a6 by Eli Bendersky in branch '2.7':
Issue #13612: Fix a buffer overflow in case of a multi-byte encoding.
http://hg.python.org/cpython/rev/b3efc140d8a6

--

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



[issue18647] re.error: nothing to repeat

2013-08-04 Thread Eli Bendersky

Eli Bendersky added the comment:

Would it not be better to temporarily-fix the test rather than the code?

--
nosy: +eli.bendersky

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



[issue18654] modernize mingwcygwin compiler classes

2013-08-04 Thread Roumen Petrov

Roumen Petrov added the comment:

Proposed customization allow users to build extension module for windows with 
GNU compiler in all environments:
- native with installed official build of python for windows
- native either MSYS or CYGWIN enviroment and python build with GCC
- cross-build in cygwin using official build of python for windows
- cross-build in cygwin or linux with use of preset configuration from 
distribution
- cross-build in linux and cross build python with GCC

In addition patch allow user to build (native or cross) core modules with 
recent gnu compilers.

--
keywords: +patch
Added file: 
http://bugs.python.org/file31152/0011-MINGW-compiler-customize-mingw-cygwin-compilers.patch

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



[issue18653] mingw-meta: build core modules

2013-08-04 Thread Roumen Petrov

Roumen Petrov added the comment:

This patch require modernize mingwcygwin compiler classes now opened as 
separate issue18654 .

--

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



[issue18652] Add itertools.coalesce

2013-08-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

def coalesce(iterable, default=None, pred=None):
return next(filter(pred, iterable), default)

Are you sure you want add this one-line function to the itertools module rather 
then to recipes?

--

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



[issue18647] re.error: nothing to repeat

2013-08-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

All doctests affected.

--

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



[issue17684] Skip tests in test_socket like testFDPassSeparate on OS X

2013-08-04 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b7d764807343 by Charles-Francois Natali in branch '3.3':
Issue #17684: Fix some test_socket failures due to limited FD passing support
http://hg.python.org/cpython/rev/b7d764807343

--

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



[issue18647] re.error: nothing to repeat

2013-08-04 Thread Eli Bendersky

Eli Bendersky added the comment:

Wonderfully terse, as usual. Can you be so kind to elaborate just a tiny bit 
more? Is the amount of doctests this affects so large that it's better to 
change the implementation? What are the plans for this temporary stage - is 
there an intention to fix the code soon and revert the disabling of this 
error check?

--

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



[issue17684] Skip tests in test_socket like testFDPassSeparate on OS X

2013-08-04 Thread Charles-François Natali

Charles-François Natali added the comment:

 Charles-Francois: why did you commit this to default only, and not
 to 3.3?

I overlooked it (apparently, the issue was tagged 3.4 only, and I didn't 
double-check that the code was present in 3.3 as well).

Should be better now!

--
versions: +Python 3.3

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



[issue18655] GUI apps take long to launch on Windows

2013-08-04 Thread netrick

New submission from netrick:

On both Python 2 or 3, when you have GUI app (for example something in pygame 
or pyside or tk), when you launch it on Windows it takes about 4-6 seconds to 
display the Window for the first run. The next runs are faster, but only untill 
you reboot the PC.

The thing is that on Linux even when launching the script for first time ever, 
the GUI Window shows instantly. 

Something how Python displays windows on Windows is wrong, there is something 
that causes the serious lag.

You can see it very easy with IDLE. On Linux it launches instantly, on Windows 
XP on the same PC takes about 6 seconds to launch. I asked other people with 
different config and they have the same issue on Windows.

--
components: Windows
messages: 194374
nosy: netrick
priority: normal
severity: normal
status: open
title: GUI apps take long to launch on Windows
type: performance
versions: Python 2.7, Python 3.3

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



[issue9148] os.execve puts process to background on windows

2013-08-04 Thread Piotr Dobrogost

Changes by Piotr Dobrogost p...@bugs.python.dobrogost.net:


--
nosy: +piotr.dobrogost

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



[issue17605] mingw-meta: build interpeter core

2013-08-04 Thread Roumen Petrov

Roumen Petrov added the comment:

please follow build of core modules - issue18653 .

--

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



[issue18649] list2cmdline function in subprocess module handles \ sequence wrong

2013-08-04 Thread Richard Oudkerk

Richard Oudkerk added the comment:

Firstly, list2cmdline() takes a list as its argument, not a string:

   import subprocess
   print subprocess.list2cmdline([r'\1|2\'])
  \\\1|2\\\

But the problem with passing arguments to a batch file is that cmd.exe parses 
arguments differently from how normal executables do.  In particular, | is 
treated specially and ^ is used as an escape character.

If you define test.bat as

  @echo off
  echo %1

then

  subprocess.call(['test.bat', '1^|2'])

prints

  1|2

as expected.

This is a duplicate of http://bugs.python.org/issue1300.

--
nosy: +sbt
resolution:  - invalid
stage:  - committed/rejected
status: open - closed
type:  - behavior

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



[issue6335] Add support for mingw

2013-08-04 Thread Roumen Petrov

Roumen Petrov added the comment:

I would like to config that path to this issue is one of those for issue3871 - 
my patch for 2.6/2.7  enhanced by ?? (sorry I forgot user :( )  for 3.0 .

Now as requested all in one patch is split and first set is listed in 
issue17605 build interpeter core, second issue18653 build core modules plus 
modernization of mingwcygwin compiler classes in scope of issue18654 .

--

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



[issue9148] os.execve puts process to background on windows

2013-08-04 Thread Matt Joiner

Changes by Matt Joiner anacro...@gmail.com:


--
nosy: +anacrolix

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



[issue17684] Skip tests in test_socket like testFDPassSeparate on OS X

2013-08-04 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Thanks!

--

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



[issue9098] MSYS build fails with `S_IXGRP' undeclared

2013-08-04 Thread Roumen Petrov

Changes by Roumen Petrov bugtr...@roumenpetrov.info:


--
nosy: +rpetrov

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



[issue18652] Add itertools.coalesce

2013-08-04 Thread Hynek Schlawack

Hynek Schlawack added the comment:

 def coalesce(iterable, default=None, pred=None):
return next(filter(pred, iterable), default)
 
 Are you sure you want add this one-line function to the itertools module 
 rather then to recipes?

Well, for many – including me – it would mean to have this one-line function in 
every other project or a PyPI dependency.  I’m certain there are other short 
but useful functions in the stdlib.

--

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



[issue15315] Can't build Python extension with mingw32 on Windows

2013-08-04 Thread Roumen Petrov

Changes by Roumen Petrov bugtr...@roumenpetrov.info:


--
nosy: +rpetrov

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



[issue4709] Mingw-w64 and python on windows x64

2013-08-04 Thread Roumen Petrov

Changes by Roumen Petrov bugtr...@roumenpetrov.info:


--
nosy: +rpetrov

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



[issue9148] os.execve puts process to background on windows

2013-08-04 Thread Piotr Dobrogost

Piotr Dobrogost added the comment:

This is unexpected and makes people wonder what's going on. See 
http://stackoverflow.com/q/7004687/95735 and 
http://stackoverflow.com/q/7264571/95735.

--

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



[issue18649] list2cmdline function in subprocess module handles \ sequence wrong

2013-08-04 Thread Piotr Dobrogost

Piotr Dobrogost added the comment:

I think you're missing the point. The implementation is wrong as it does not do 
what documentation says which is A double quotation mark preceded by a 
backslash is interpreted as a literal double quotation mark. How the output of 
list2cmdline interacts with the cmd.exe is another issue (It just happens here 
that if implementation of list2cmdline were in line with its documentation then 
there wouldn't be any subsequent problem with cmd.exe). Also issue 1300 is 
about escaping a pipe character (|) on the basis of how it's treated by cmd.exe 
and does not even refer to the docstring of list2cmdline function.

--
resolution: invalid - 
status: closed - open

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



[issue18655] GUI apps take long to launch on Windows

2013-08-04 Thread Ramchandra Apte

Ramchandra Apte added the comment:

Can you provide a short script that reproduces this problem?
AFAIK, Python doesn't display windows, the tcl/pygame libraries' C code creates 
the windows.

--
nosy: +Ramchandra Apte

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



  1   2   >