MacroPy 0.1.2: Macros for Pythoon. Quasiquotes, Case Classes, Pattern Matching, LINQ and more!

2013-05-09 Thread Haoyi Li
Hey All,

MacroPy is an implementation of Macros in the Python Programming, providing a 
mechanism for user-defined functions (macros) to perform transformations on the 
abstract syntax tree(AST) of Python code at module import time. This is an easy 
way to modify the semantics of a python program in ways which are otherwise 
impossible, for example providing an extremely concise way of declaring classes:

@case
class Point(x, y)

p = Point(1, 2)
print p.x   # 1
print p # Point(1, 2)

Apart from this, we've used MacroPy's macros to implement a pretty impressive 
list of features:

- Quasiquotes
- String Interpolation
- Pyxl, integrating XML markup into a Python program
- Tracing and Smart Asserts
- Case Classes, easy Algebraic Data Types from Scala
- Pattern Matching from the Functional Programming world
- LINQ to SQL from C#
- Quick Lambdas from Scala and Groovy,
- Parser Combinators, inspired by Scala's.

The full documentation is over on github (https://github.com/lihaoyi/macropy) 
if anyone wants to check it out. It runs fine on both CPython 2.7 and PyPy 1.9, 
and I've just pushed the last up-to-date version of MacroPy to PyPI: 

https://pypi.python.org/pypi/MacroPy 

Hope someone finds this useful! 

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

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Append to python List

2013-05-09 Thread RAHUL RAJ
Checkout the following code:

sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]   
output=[]
output=[x for x in sample2 if x not in output]

the output I get is
3 4 5 6 7 8 9 10 3 5 6 7 8 9 10 11 4 5 7 8 9 10 11 12 5 6 7 9 10 11 12 13 6 7 8 
9 11 12 13 14 7 8 9 10 11 13 14 15 8 9 10 11 12 13 15 16 9 10 11 12 13 14 15 17 
10 11 12 13 14 15 16 17

which contains duplicate values.




But if I do like this:

sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]   
output=[]
for x in sample2:
  if x not in output:
 output.append(x)


the value of 'output' I get like this:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

I know that both the programs have the same functionality, but why do I have 
different outputs?

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


Re: object.enable() anti-pattern

2013-05-09 Thread Terry Jan Reedy

On 5/9/2013 1:23 AM, Steven D'Aprano wrote:


Besides, this is not to denigrate the idea of a read() function that
takes a filename and returns its contents. But that is not an object
constructor. It may construct a file object internally, but it doesn't
return the file object, so it is completely unrelated to the scenario I
described.


At least a few stdlib modules that define classes *also* have such 
functions. They create an instance of the class, call one or more 
methods, and return the result of the method, discarding the instance. 
For instance, see the subprocess module, its POpen class, and module 
functions; or the timeit module, its Timer class, and functions.



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


Re: Help with implementing callback functions using ctypes

2013-05-09 Thread Stefan Behnel
dieter, 09.05.2013 07:54:
 jamadagni writes:
 ...
 I cannot help you with ctypes. But, if you might be able to use
 cython, then calling callbacks is not too difficult

+1 for using Cython. It also has (multi-)source level gdb support, which
greatly helps in debugging crashes like this one.

http://docs.cython.org/src/userguide/debugging.html


 (you can find an example in e.g. my dm.xmlsec.binding).

An official example is here:

https://github.com/cython/cython/tree/master/Demos/callback


 Note, however, that properly handling the GIL (Global Interpreter Lock)
 may be of great importance when the Python/C boundary is crossed --
 at least when you intend to use your code in a multi thread environment.

Cython makes this really easy. You can use the with statement to release
the GIL when you don't need it, and the compiler will produce errors when
you try to do things that require the GIL while you don't own it.

Stefan


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


Re: Append to python List

2013-05-09 Thread Jussi Piitulainen
RAHUL RAJ writes:

 Checkout the following code:
 
 sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]   
 output=[]
 output=[x for x in sample2 if x not in output]
 
 the output I get is
 3 4 5 6 7 8 9 10 3 5 6 7 8 9 10 11 4 5 7 8 9 10 11 12 5 6 7 9 10 11
 12 13 6 7 8 9 11 12 13 14 7 8 9 10 11 13 14 15 8 9 10 11 12 13 15 16
 9 10 11 12 13 14 15 17 10 11 12 13 14 15 16 17
 
 which contains duplicate values.

The second comprehension, [x for x in sample2 if x not in output], in
the context, is equivalent to [x for x in sample2 if x not in []]. It
does not refer to an incomplete version of the list that gets assigned
to the variable after it's done.
-- 
http://mail.python.org/mailman/listinfo/python-list


Forming a small python programming group

2013-05-09 Thread kreta06
Hi All,

I'm looking for one or two medium-advanced python programmers to
practice programming on a Windows 7 platform. In addition, any
interests in writing python code to query Microsoft SQL databases
(2005-2008) is also welcomed.

I've coded in python 2.7 and currently am trying to make the switch to
3.2 as there seem to be some changes to the syntax. I'm only available
on a weekend basis and occasionally some week days. Therefore, in
terms of output, probably  2-3 scripts per month. If you are
interested in working with me, please send me an email on similar
interests and we can start this next week.

Best regards,
Sue
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append to python List

2013-05-09 Thread Gary Herron

On 05/08/2013 11:36 PM, RAHUL RAJ wrote:

Checkout the following code:

sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]
output=[]



output=[x for x in sample2 if x not in output]
This statement is not doing what you expect.  It is not building a list 
in the variable named output, it is building a list (anonymously) then 
binding it to the variable output once it's built.  Therefore output is 
[] for the whole list building operation.


The later operation works, because your *are* building the list in place 
as you go.




the output I get is
3 4 5 6 7 8 9 10 3 5 6 7 8 9 10 11 4 5 7 8 9 10 11 12 5 6 7 9 10 11 12 13 6 7 8 
9 11 12 13 14 7 8 9 10 11 13 14 15 8 9 10 11 12 13 15 16 9 10 11 12 13 14 15 17 
10 11 12 13 14 15 16 17

which contains duplicate values.




But if I do like this:

sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]
output=[]
for x in sample2:
   if x not in output:
  output.append(x)


the value of 'output' I get like this:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

I know that both the programs have the same functionality, but why do I have 
different outputs?

Please help!


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


Re: Append to python List

2013-05-09 Thread Chris Angelico
On Thu, May 9, 2013 at 4:36 PM, RAHUL RAJ omrahulraj...@gmail.com wrote:
 output=[x for x in sample2 if x not in output]

 output=[]
 for x in sample2:
   if x not in output:
  output.append(x)

The first one constructs a list, then points the name 'output' at it.
The second one builds up a list, with 'output' pointing at it all the
way. Your first one is more like:

sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]
output=[]
_temp=[]
for x in sample2:
  if x not in output:
 _temp.append(x)
output=_temp

You may want to consider using a set, instead.

 {x+y for x in range(1,10) for y in range(1,10) if x!=y}
{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}

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


Re: object.enable() anti-pattern

2013-05-09 Thread Gregory Ewing

Steven D'Aprano wrote:
There is no sensible use-case for creating a file without opening it. 
What would be the point?


Early unix systems often used this as a form of locking.

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


Re: Forming a small python programming group

2013-05-09 Thread Terry Jan Reedy

On 5/9/2013 2:59 AM, kreta06 wrote:

Hi All,

I'm looking for one or two medium-advanced python programmers to
practice programming on a Windows 7 platform. In addition, any
interests in writing python code to query Microsoft SQL databases
(2005-2008) is also welcomed.

I've coded in python 2.7 and currently am trying to make the switch to
3.2 as there seem to be some changes to the syntax.


Start with 3.3 unless you *must* use 3.2. There is one less syntax 
change and a better unicode string implementation.




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


Re: Append to python List

2013-05-09 Thread RAHUL RAJ
Then what about this code part?

[(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]

and the following code part:

for x in [1,2,3]:
  for y in [3,1,4]:
if x != y:
  combs.append((x, y))


On Thursday, May 9, 2013 12:24:24 PM UTC+5:30, Gary Herron wrote:
 On 05/08/2013 11:36 PM, RAHUL RAJ wrote:
 
  Checkout the following code:
 
 
 
  sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]
 
  output=[]
 
 
 


  output=[x for x in sample2 if x not in output]
 
 This statement is not doing what you expect.  It is not building a list 
 
 in the variable named output, it is building a list (anonymously) then 
 
 binding it to the variable output once it's built.  Therefore output is 
 
 [] for the whole list building operation.
 
 
 
 The later operation works, because your *are* building the list in place 
 
 as you go.
 
 
 
 
 
  the output I get is
 
  3 4 5 6 7 8 9 10 3 5 6 7 8 9 10 11 4 5 7 8 9 10 11 12 5 6 7 9 10 11 12 13 6 
  7 8 9 11 12 13 14 7 8 9 10 11 13 14 15 8 9 10 11 12 13 15 16 9 10 11 12 13 
  14 15 17 10 11 12 13 14 15 16 17
 
 
 
  which contains duplicate values.
 
 
 
 
 
 
 
 
 
  But if I do like this:
 
 
 
  sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]
 
  output=[]
 
  for x in sample2:
 
 if x not in output:
 
output.append(x)
 
 
 
 
 
  the value of 'output' I get like this:
 
  3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 
 
 
  I know that both the programs have the same functionality, but why do I 
  have different outputs?
 
 
 
  Please help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append to python List

2013-05-09 Thread RAHUL RAJ
I'm getting same output for both code parts, why not for th code parts in 
question?

On Thursday, May 9, 2013 1:48:51 PM UTC+5:30, RAHUL RAJ wrote:
 Then what about this code part?
 
 
 
 [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]
 
 
 
 and the following code part:
 
 
 
 for x in [1,2,3]:
 
   for y in [3,1,4]:
 
 if x != y:
 
   combs.append((x, y))
 
 
 
 
 
 On Thursday, May 9, 2013 12:24:24 PM UTC+5:30, Gary Herron wrote:
 
  On 05/08/2013 11:36 PM, RAHUL RAJ wrote:
 
  
 
   Checkout the following code:
 
  
 
  
 
  
 
   sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]
 
  
 
   output=[]
 
  
 
  
 
  
 
 
 
 
 
   output=[x for x in sample2 if x not in output]
 
  
 
  This statement is not doing what you expect.  It is not building a list 
 
  
 
  in the variable named output, it is building a list (anonymously) then 
 
  
 
  binding it to the variable output once it's built.  Therefore output is 
 
  
 
  [] for the whole list building operation.
 
  
 
  
 
  
 
  The later operation works, because your *are* building the list in place 
 
  
 
  as you go.
 
  
 
  
 
  
 
  
 
  
 
   the output I get is
 
  
 
   3 4 5 6 7 8 9 10 3 5 6 7 8 9 10 11 4 5 7 8 9 10 11 12 5 6 7 9 10 11 12 13 
   6 7 8 9 11 12 13 14 7 8 9 10 11 13 14 15 8 9 10 11 12 13 15 16 9 10 11 12 
   13 14 15 17 10 11 12 13 14 15 16 17
 
  
 
  
 
  
 
   which contains duplicate values.
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
   But if I do like this:
 
  
 
  
 
  
 
   sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]
 
  
 
   output=[]
 
  
 
   for x in sample2:
 
  
 
  if x not in output:
 
  
 
 output.append(x)
 
  
 
  
 
  
 
  
 
  
 
   the value of 'output' I get like this:
 
  
 
   3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 
  
 
  
 
  
 
   I know that both the programs have the same functionality, but why do I 
   have different outputs?
 
  
 
  
 
  
 
   Please help!

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


Re: PIL: check if image is animated

2013-05-09 Thread Sven
Figured out my issue. I did called the check_animated function more than
once and the second call causes the exception unless I seek back to 0


On 6 May 2013 21:57, Sven sven...@gmail.com wrote:

 Hello,

 I am trying to check if an image is animated. I can't rely on the
 extension as it may be a gif that's been renamed to .jpg or something else
 and is still animated.

 I thought that this used to work:

 from PIL import Image


 def check_animated(img):
 try:
 img.seek(1)
 except (EOFError):
 return 0
 return 1

 img = Image('image.jpg')
 print animated?, check_animated(img)

 Regardless if it's animated or not I get this exception:
 ValueError: cannot seek to frame 1

 I need to return 0 or 1, so excuse not using True or False.

 Did the above get deprecated/change in a version at some point? Perhaps
 there's something I missed during install (using PIP). Are there any other
 ways to accomplish what I am trying to do, with or without PIL?

 Python 2.7, linux

 --
 ./Sven




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


Re: object.enable() anti-pattern

2013-05-09 Thread Cameron Simpson
On 09May2013 19:54, Greg Ewing greg.ew...@canterbury.ac.nz wrote:
| Steven D'Aprano wrote:
| There is no sensible use-case for creating a file without opening
| it. What would be the point?
| 
| Early unix systems often used this as a form of locking.

Not just early systems: it's a nice lightweight method of making a
lockfile even today if you expect to work over NFS, where not that
many things are synchronous. You open a file with 0 modes, so
that it is _immediately_ not writable. Other attempts to make the
lock file thus fail because of the lack of write, even over NFS.

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

You can listen to what everybody says, but the fact remains that you've got
to get out there and do the thing yourself. - Joan Sutherland
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anybody familiar with pygments ?

2013-05-09 Thread Fábio Santos
On 9 May 2013 05:19, dabaichi valben...@outlook.com wrote:

 And hereis the output file:

That's not the output file. That is just an HTML fragment to put on your
page. A full HTML file will need more things, which is the reason why you
don't see color output.

 I want to know why output html file with no color ?

Because there is no CSS. The output  has a lot of span tags with classes.
You are supposed to use a CSS file along with it.

So, first put that output into a complete HTML document (with a head, a
body...) And in that document add or link to your CSS file with the color
information. I never used pygments but there may be some readily available.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help on Implementing a list of dicts with no data pattern

2013-05-09 Thread rlelis
On Thursday, May 9, 2013 12:47:47 AM UTC+1, rlelis wrote:
 Hi guys,
 
 
 
 I'm working on this long file, where i have to keep reading and
 
 storing different excerpts of text (data) in different variables (list).
 
 
 
 Once done that i want to store in dicts the data i got from the lists 
 mentioned before. I want them on a list of dicts for later RDBMs purpose's.
 
 
 
 The data i'm working with, don't have fixed pattern (see example bellow), so 
 what i'm doing is for each row, i want to store combinations of  word/value 
 (Key-value) to keep track of all the data.
 
 
 
 My problem is that once i'm iterating over the list (original one a.k.a 
 file_content in the link), then i'm nesting several if clause to match
 
 the keys i want. Done that i select the keys i want to give them values and 
 lastly i append that dict into a new list. The problem here is that i end up 
 always with the last line repeated several times for each row it found's.
 
 
 
 Please take a look on what i have now:
 
 http://pastebin.com/A9eka7p9

Sorry, i thought that a link to pastebin could be helpfully since it captures 
the syntax highlights and spacings. I don't have a fifty line code there. The 
25 lines below, where to show you guys a picture of what is going on, to be 
more intuitive.
This is what i have for now:

highway_dict = {}
aging_dict = {}
queue_row = []
for content in file_content:
if 'aging' in content:
# aging 0 100
collumns = ''.join(map(str, 
content[:1])).replace('-','_').lower()
total_values =''.join(map(str, content[1:2]))
aging_values = ''.join(map(str, content[2:]))

aging_dict['total'], aging_dict[collumns] = total, aging_values
queue_row.append(aging_dict)

if 'highway' in content:
#highway|   4   |   disable |   25
collumns = ''.join(map(str, 
content[:1])).replace('-','_').lower()
lanes_values  =''.join(map(str, content[1:2]))  
state_values = ''.join(map(str, content[2:3])).strip('')
limit_values = ''.join(map(str, content[3:4])).strip('')

highway_dict['lanes'], highway_dict['state'], 
highway_dict['limit(mph)'] = lanes, state, limit_values
queue_row.append(highway_dict)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Style question -- plural of class name?

2013-05-09 Thread Thomas Rachel

Am 09.05.2013 02:38 schrieb Colin J. Williams:

On 08/05/2013 4:20 PM, Roy Smith wrote:


A list of FooEntry's  +1


Go back to school. Both of you...

That is NOT the way to build a plural form...


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


Re: object.enable() anti-pattern

2013-05-09 Thread Wayne Werner



On Wed, 8 May 2013, Steven D'Aprano wrote:


I'm looking for some help in finding a term, it's not Python-specific but
does apply to some Python code.

This is an anti-pattern to avoid. The idea is that creating a resource
ought to be the same as turning it on, or enabling it, or similar. For
example, we don't do this in Python:


I'm not entirely sure what the name of it is, but the basic concept is 
that you should never partially create, or create a class that can be in 
an unstable state. Which isn't to say you should prevent invalid input, 
only that with every valid input or single operation (including 
construction) your class should be valid.



Ah, that's it - the problem is that it introduces /Temporal Coupling/ to 
one's code: http://blog.ploeh.dk/2011/05/24/DesignSmellTemporalCoupling/


You don't ever want a class that has functions that need to be called in a 
certain order to *not* crash. That's fine if you have to call them in a 
certain sequence in order to get the correct data - that's what 
programming is all about, after all. But if you provide me a class with a 
constructor you better make sure that when I do this:


thing = YourSuperAwesomeClass()
thing.do_stuff()

that I don't get some horrid stack trace ending with

InvalidStateError: initialize() needs to be called before do_stuff()

Or something worse.


HTH,
Wayne

p.s. I'm interested in reading whatever is evenually written on the topic
--
http://mail.python.org/mailman/listinfo/python-list


Re: Append to python List

2013-05-09 Thread Steven D'Aprano
On Thu, 09 May 2013 01:18:51 -0700, RAHUL RAJ wrote:

 Then what about this code part?


What about it? 


 [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]
 
 and the following code part:
 
 for x in [1,2,3]:
   for y in [3,1,4]:
 if x != y:
   combs.append((x, y))

Apart from not defined combs, those two pieces of code are equivalent.

So what is your question?


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


Re: Append to python List

2013-05-09 Thread 88888 Dihedral
Jussi Piitulainen於 2013年5月9日星期四UTC+8下午2時55分20秒寫道:
 RAHUL RAJ writes:
 
 
 
  Checkout the following code:
 
  
 
  sample2 = [x+y for x in range(1,10) for y in range(1,10) if x!=y]   
 
  output=[]
 
  output=[x for x in sample2 if x not in output]
 
  
 
  the output I get is
 
  3 4 5 6 7 8 9 10 3 5 6 7 8 9 10 11 4 5 7 8 9 10 11 12 5 6 7 9 10 11
 
  12 13 6 7 8 9 11 12 13 14 7 8 9 10 11 13 14 15 8 9 10 11 12 13 15 16
 
  9 10 11 12 13 14 15 17 10 11 12 13 14 15 16 17
 
  
 
  which contains duplicate values.
 
 
 
 The second comprehension, [x for x in sample2 if x not in output], in
 
 the context, is equivalent to [x for x in sample2 if x not in []]. It
 
 does not refer to an incomplete version of the list that gets assigned
 
 to the variable after it's done.

This is just the handy style for a non-critical loop.
In a critical loop, the number of  the total operation counts
does matter in the execution speed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Append to python List

2013-05-09 Thread Jussi Piitulainen
8 Dihedral writes:

 This is just the handy style for a non-critical loop.
 In a critical loop, the number of  the total operation counts
 does matter in the execution speed.

Do you use speed often?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object.enable() anti-pattern

2013-05-09 Thread Steven D'Aprano
On Thu, 09 May 2013 18:23:31 +1000, Cameron Simpson wrote:

 On 09May2013 19:54, Greg Ewing greg.ew...@canterbury.ac.nz wrote:
 | Steven D'Aprano wrote:
 |  There is no sensible use-case for creating a file WITHOUT OPENING
 |  it. What would be the point?
 |
 | Early unix systems often used this as a form of locking.
 
 Not just early systems: it's a nice lightweight method of making a
 lockfile even today if you expect to work over NFS, where not that many
 things are synchronous. You OPEN A FILE with 0 modes

[emphasis added]

This is all very well and good, but for the life of me, I cannot see how 
opening a file is a good example of not opening a file. Perhaps it is a 
Zen thing, like the sound no spoon makes when you don't tap it against a 
glass that isn't there.


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


Re: object.enable() anti-pattern

2013-05-09 Thread Steven D'Aprano
On Thu, 09 May 2013 06:08:25 -0500, Wayne Werner wrote:

 Ah, that's it - the problem is that it introduces /Temporal Coupling/ to
 one's code: http://blog.ploeh.dk/2011/05/24/DesignSmellTemporalCoupling/

Good catch!

That's not the blog post I read, but that's the same concept. Temporal 
Coupling -- yes, that is an excellent description of the problem.


 You don't ever want a class that has functions that need to be called in
 a certain order to *not* crash. That's fine if you have to call them in
 a certain sequence in order to get the correct data - that's what
 programming is all about, after all. But if you provide me a class with
 a constructor you better make sure that when I do this:
 
  thing = YourSuperAwesomeClass()
  thing.do_stuff()
 
 that I don't get some horrid stack trace ending with
 
  InvalidStateError: initialize() needs to be called before
  do_stuff()
 
 Or something worse.

Exactly.


Thank you Wayne, that's a great help.



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


Alternate computational models can be harmonious (was Message passing syntax for objects | OOPv2)

2013-05-09 Thread rusi
On May 9, 10:39 am, Steven D'Aprano steve
+comp.lang.pyt...@pearwood.info wrote:
 On Wed, 08 May 2013 19:35:58 -0700, Mark Janssen wrote:
  Long story short: the lambda
  calculus folks have to split from the Turing machine folks.
   These models of computation should not use the same language.  Their
  computation models are too radically different.

 Their computation models are exactly equivalent.

 This is like saying that Cartesian coordinates and polar coordinates are
 so radically different that they cannot possibly both describe the same
 space.

Spot on Steven -- thanks.

And further we do know that from a pragmatic POV the two can be quite
different.
For example cartesian are easier for add/subtract, whereas polar are
easier for multiply/divide.
And so on occasion the best way of doing an operation is to -- if
necessary -- convert to the more appropriate format.

I feel that the case of alternate computation models is analogous --
for some purposes one model works well and sometimes another.

Python embeds the functional model almost as natively as it does the
imperative/OO model.  This is an aspect of python that is powerful but
can also make it hard for some people. In short, python's multi-
paradigm possibilities could do with some good publicity.

My own attempts at bringing functional thinking to classical
imperative languages and Python in particular, will be up at:
https://moocfellowship.org/submissions/the-dance-of-functional-programming-languaging-with-haskell-and-python

It is also an attempt at bringing the lightness and freedom of Python
to the Haskell community and answer divisive judgements of
computational models/paradigms such as the OP's.

More details at 
http://blog.languager.org/2013/05/dance-of-functional-programming.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help on Implementing a list of dicts with no data pattern

2013-05-09 Thread Dave Angel

On 05/09/2013 05:57 AM, rlelis wrote:

On Thursday, May 9, 2013 12:47:47 AM UTC+1, rlelis wrote:

Hi guys,



I'm working on this long file, where i have to keep reading and

storing different excerpts of text (data) in different variables (list).



Once done that i want to store in dicts the data i got from the lists mentioned 
before. I want them on a list of dicts for later RDBMs purpose's.



The data i'm working with, don't have fixed pattern (see example bellow), so 
what i'm doing is for each row, i want to store combinations of  word/value 
(Key-value) to keep track of all the data.



My problem is that once i'm iterating over the list (original one a.k.a 
file_content in the link), then i'm nesting several if clause to match

the keys i want. Done that i select the keys i want to give them values and 
lastly i append that dict into a new list. The problem here is that i end up 
always with the last line repeated several times for each row it found's.



Please take a look on what i have now:

http://pastebin.com/A9eka7p9


Sorry, i thought that a link to pastebin could be helpfully since it captures 
the syntax highlights and spacings. I don't have a fifty line code there. The 
25 lines below, where to show you guys a picture of what is going on, to be 
more intuitive.
This is what i have for now:



The entire following set of comments is probably outdated since you 
apparently did NOT use readlines() or equivalent to get file_content. 
So you'd better give us some sample data, a program that can actually 
run without getting exceptions due to misnamed variables, and a 
description of just what you expected to be in each result variable.


It'd also be smart to mention what version of Python you're targeting.

 what follows was a waste of my time ...

file_content is not defined, but we can guess you have read it from a 
text file with readlines(), or more efficiently that it's simply a file 
object for a file opened with r.  Can we see sample data, maybe for 3 
or four lines?


file_content = [
A4 value2 aging,
b8 value99 paging,
-1 this is aging a test,
B2  repeaagingts,
]

The sample, or the description, should indicate if repeats of the 
columns column are allowed, as with b and B above.



highway_dict = {}
aging_dict = {}
queue_row = []
for content in file_content:
if 'aging' in content:
# aging 0 100
collumns = ''.join(map(str, 
content[:1])).replace('-','_').lower()
total_values =''.join(map(str, content[1:2]))
aging_values = ''.join(map(str, content[2:]))


Those three lines would be much more reasonable and readable if you 
eliminated all the list stuff, and just did what was needed.  Also, 
calling a one-character string collumns or total_values makes no 
sense to me.


collumns = content[:1].replace('-','_').lower()
total_values = content[1:2]
aging_values = content[2:]



aging_dict['total'], aging_dict[collumns] = total, aging_values


That line tries to get clever, and ends up obscuring what's really 
happening.  Further, the value in total, if any is NOT what you just 
extracted in total_values.

aging_dict['total'] = total
aging_dict[collumns] = aging_values



queue_row.append(aging_dict)


Just what do you expect to be in the aging_dict here?  If you intended 
that each item of queue_row contains a dict with just one item, then you 
need to clear aging_dict each time through the loop.  As it stands the 
list ends up with a bunch of dicts, each with possibly one more entry 
than the previous dict.


All the same remarks apply to the following code.  Additionally, you 
don't use collumns for anything, and you use lanes and state when you 
presumably meant lanes_values and state_values.


if 'highway' in content:




#highway|   4   |   disable |   25
collumns = ''.join(map(str, 
content[:1])).replace('-','_').lower()
lanes_values  =''.join(map(str, content[1:2]))  
state_values = ''.join(map(str, content[2:3])).strip('')
limit_values = ''.join(map(str, content[3:4])).strip('')

highway_dict['lanes'], highway_dict['state'], 
highway_dict['limit(mph)'] = lanes, state, limit_values
queue_row.append(highway_dict)



Now, when

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


Re: Making safe file names

2013-05-09 Thread Roy Smith
In article 518b133b$0$29997$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 I suspect that the only way to be completely ungoogleable would be to 
 name yourself something common, not something obscure.

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


Re: object.enable() anti-pattern

2013-05-09 Thread Roy Smith
In article 518b32ef$0$11120$c3e8...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 
 There is no sensible use-case for creating a file without opening it.

Sure there is.  Sometimes just creating the name in the file system is 
all you want to do.  That's why, for example, the unix touch command 
exists.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help on Implementing a list of dicts with no data pattern

2013-05-09 Thread Neil Cerutti
On 2013-05-09, rlelis ricardo.lel...@gmail.com wrote:
 This is what i have for now:

 highway_dict = {}
 aging_dict = {}
 queue_row = []
 for content in file_content:
   if 'aging' in content:
   # aging 0 100
   collumns = ''.join(map(str, 
 content[:1])).replace('-','_').lower()
   total_values =''.join(map(str, content[1:2]))
   aging_values = ''.join(map(str, content[2:]))

   aging_dict['total'], aging_dict[collumns] = total, aging_values
   queue_row.append(aging_dict)

   if 'highway' in content:
   #highway|   4   |   disable |   25
   collumns = ''.join(map(str, 
 content[:1])).replace('-','_').lower()
   lanes_values  =''.join(map(str, content[1:2]))  
   state_values = ''.join(map(str, content[2:3])).strip('')
   limit_values = ''.join(map(str, content[3:4])).strip('')
   
   highway_dict['lanes'], highway_dict['state'], 
 highway_dict['limit(mph)'] = lanes, state, limit_values
   queue_row.append(highway_dict)

Can you provide a short example of input and what you had hoped
to see in the lists and dicts at the end?

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


Re: object.enable() anti-pattern

2013-05-09 Thread Oscar Benjamin
On 9 May 2013 14:07, Roy Smith r...@panix.com wrote:
 In article 518b32ef$0$11120$c3e8...@news.astraweb.com,
  Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 There is no sensible use-case for creating a file without opening it.

 Sure there is.  Sometimes just creating the name in the file system is
 all you want to do.  That's why, for example, the unix touch command
 exists.

Wouldn't the code that implements the touch command just look
something like this:

f = open(filename)
f.close()

Or is there some other way of creating the file that doesn't open it
(I mean in general not just in Python)?


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


Re: Red Black Tree implementation?

2013-05-09 Thread duncan smith

On 09/05/13 02:40, Dan Stromberg wrote:

OK, I've got one copy of trees.py with md5
211f80c0fe7fb9cb42feb9645b4b3ffe.  You seem to be saying I should have
two though, but I don't know that I do...



[snip]

Yes, 211f80c0fe7fb9cb42feb9645b4b3ffe is the correct checksum for the 
latest version. The previous version had an issue when adding 
non-distinct items (items that compare equal to items already in the 
tree). Cheers.


Duncan

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


Re: help on Implementing a list of dicts with no data pattern

2013-05-09 Thread rlelis
I apologize once again. 
Is my first post here and i'm getting used to the group as long as i get the 
feedback of my errors by you guys.
I'm using Python 2.7.3 with no dependencies, i'm simply using the standard
library.
Here is the big picture of the scenario(i have added it in the pastebin link 
too) 

FILE OUTPUT DESIRED:
aging:
aging  |total |age
aging  |0 |100
aging  |2 |115
aging  |3 |1
aging  |4 |10

highway:
highway   | lanes |   state   |   limit(mph)
highway   |   4   |   disable |   25
highway   |   2   |   disable |   245
highway   |   3   |   disable |   125
highway   |   2   |   enable  |   255
highway   |   3   |   disable |   212
highway   |   8   |   disable |   78

FILE INPUT EXCERPT EXAMPLE:
aging 0 100
aging 2 115
aging 3 1
highway 4 disable 25
highway 2 disable 245
highway 0 enable 125

Meanwhile i have change the code a little bit and achieve a output closer to 
what i want:
highway_dict = {}
aging_dict = {}
queue_counters={}
queue_row = []
for content in file_content: 
if 'aging' in content:
# aging 0 100
columns = ', '.join(map(str, 
content[:1])).replace('-','_').lower()
total_values =''.join(map(str, content[1:2]))
aging_values = '\t'.join(map(str, content[2:]))
 
aging_dict['total'], aging_dict[columns] = total, aging_values
queue_counters[columns] = aging_dict
if 'highway' in content:
#highway|   4   |   disable |   25
columns = ''.join(map(str, 
content[:1])).replace('-','_').lower()
lanes_values  =''.join(map(str, content[1:2])) 
state_values = ''.join(map(str, content[2:3])).strip('')
limit_values = ''.join(map(str, content[3:4])).strip('')
   
highway_dict['lanes'], highway_dict['state'], 
highway_dict['limit(mph)'] = lanes, state, limit_values
queue_counters[columns] = highway_dict
queue_row.append(queue_counters)

Now i'm adding the different dicts to a main one (queue_counters). The 
problem here is that i'm keeping falling on the iteration issue. I only get the 
last row on my ouput. My last printout was:

queue_counters:  {'aging': {'age': '10', 'total': '4'}, 'highway': {'lanes': 
'8','state': 'disable', 'limit': '78'}} 

@Dave Angel  

The sample, or the description, should indicate if repeats of the 
columns column are allowed, as with b and B above. 
- Yes the columns repetition are allowed.

That line tries to get clever, and ends up obscuring what's really 
happening.  Further, the value in total, if any is NOT what you just 
extracted in total_values.
- this variable name total_values means that i'm storing the content (different 
values)of the total column, and the same applies to the other columns (might
not be the best names, but don't forget that we are just prototyping here). The 
total, age, etc etc variable name i had to set them, once they don't come with 
the original file, but is important to give them names to help on RDBMs 
purposes later, and not only that, it's handy right?

The column variable refers to the object name (aging and highway). I'm doing 
that because in the original source i have to deal with string formatting of 
strange names. Remember that this is for prototyping, that's why i'm trying to 
resume things here.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help on Implementing a list of dicts with no data pattern

2013-05-09 Thread Dave Angel

On 05/09/2013 10:33 AM, rlelis wrote:

I apologize once again.
Is my first post here and i'm getting used to the group as long as i get the 
feedback of my errors by you guys.
I'm using Python 2.7.3 with no dependencies, i'm simply using the standard
library.
Here is the big picture of the scenario(i have added it in the pastebin link 
too)

FILE OUTPUT DESIRED:
aging:
aging  |total |age
aging  |0 |100
aging  |2 |115
aging  |3 |1
aging  |4 |10

highway:
highway   | lanes |   state   |   limit(mph)
highway   |   4   |   disable |   25
highway   |   2   |   disable |   245
highway   |   3   |   disable |   125
highway   |   2   |   enable  |   255
highway   |   3   |   disable |   212
highway   |   8   |   disable |   78

FILE INPUT EXCERPT EXAMPLE:
aging 0 100
aging 2 115
aging 3 1
highway 4 disable 25
highway 2 disable 245
highway 0 enable 125

Meanwhile i have change the code a little bit and achieve a output closer to 
what i want:


You're still missing the file read code.  My earlier assumption that it 
was a simple readlines() was bogus, or the line:

   if aging in file-content:

would never work.

Perhaps you have something like:

infile = open(,r)
file_content = [line.split() for line in infile]

if you confirm it, I'll try to go through the code again, trying to make 
sense of it.




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


Re: Style question -- plural of class name?

2013-05-09 Thread Neil Cerutti
On 2013-05-08, Denis McMahon denismfmcma...@gmail.com wrote:
 On Wed, 08 May 2013 16:20:48 -0400, Roy Smith wrote:

 FooEntry is a class.  How would you describe a list of these in a
 docstring?
 
 A list of FooEntries
 
 A list of FooEntrys
 
 A list of FooEntry's
 
 A list of FooEntry instances
 
 The first one certainly sounds the best, but it seems wierd to change
 the spelling of the class name to make it plural.

 I wouldn't use an apostrophe for pluralisation.

If there's no chance for confusion between a class named FooEntry
and another named FooEntries, then the first attempt seems best.
Pluralize a class name by following the usual rules, e.g.,
strings and ints.

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


Urgent:Serial Port Read/Write

2013-05-09 Thread chandan kumar
Hi all,I'm new to python and facing issue using serial in python.I'm facing the 
below error 
    ser.write(port,command)NameError: global name 'ser' is not defined
Please find the attached script and let me know whats wrong in my script and 
also how can i read data from serial port for the  same script.

Best Regards,Chandan.
import time
import os
import serial
import glob


ER_Address = [[0x0A,0x01,0x08,0x99,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB]]


Function Name: RunSequence

Function Description:
-
A RunSequence function has Multiple calls to the RunSuite function, each call 
is a single testcase consisting of all the parameters
required by the RunTesSuite.
-

def WriteSerialData(command):
ser.write(port,command)
 
def SendPacket(Packet):
str = chr(len(Packet)) + Packet #Concatenation of Packet with the 
PacketLength
print str
WriteSerialData(str)


def CreateFrame(Edata):
evt = chr(0x12)
evt = evt + chr(Edata[0])
for i in range (1, len(Edata)):
evt = evt + chr(Edata[i])
return evt

def SetRequest(data):
print data
new = []
new = sum(data, [])
Addr = CreateFrame(new)
SendPacket(Addr)
print SendPacket Done
ReadPacket()


def OpenPort(COMPort,BAUDRATE):

This function reads the serial port and writes it.

comport=COMPort
BaudRate=BAUDRATE
try:
ser = serial.Serial(
port=comport,
baudrate=BaudRate,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
timeout=10,
xonxoff=0,
rtscts=0,
dsrdtr=0
)

if ser.isOpen():
print Port Opened
ser.write(Chandan)
string1 = ser.read(8)
print string1   
return ser
else:
print Port CLosed
ser.close()
return 3
except serial.serialutil.SerialException:
print Exception
ser.close()
   
 




if __name__ == __main__:

CurrDir=os.getcwd()
files = glob.glob('./*pyc')
for f in files:
os.remove(f)
OpenPort(26,9600)
SetRequest(ER_Address)
#SysAPI.SetRequest('ER',ER_Address)

print Test Scripts Execution complete





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


Re: Urgent:Serial Port Read/Write

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 1:35 AM, chandan kumar chandan_...@yahoo.co.in wrote:

 Hi all,
 I'm new to python and facing issue using serial in python.I'm facing the 
 below error

 ser.write(port,command)
 NameError: global name 'ser' is not defined

 Please find the attached script and let me know whats wrong in my script and 
 also how can i read data from serial port for the  same script.

You're assigning to 'ser' inside OpenPort(), but then trying to use it
in WriteSerialData(). You'll need to declare 'global ser' in OpenPort
to make this work.

Alternatively, you may want to cut down on the number of functions you
have, since they're called in only one place anyway and have to share
state.

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


Re: Urgent:Serial Port Read/Write

2013-05-09 Thread Frank Miles
On Thu, 09 May 2013 23:35:53 +0800, chandan kumar wrote:

 Hi all,I'm new to python and facing issue using serial in python.I'm
 facing the below error
     ser.write(port,command)NameError: global name 'ser' is not defined
 Please find the attached script and let me know whats wrong in my script
 and also how can i read data from serial port for the  same script.
[snip]
 if __name__ == __main__:
 
 CurrDir=os.getcwd()
 files = glob.glob('./*pyc')
 for f in files:
 os.remove(f)
 OpenPort(26,9600)
 SetRequest(ER_Address)
 #SysAPI.SetRequest('ER',ER_Address)
 
 print Test Scripts Execution complete

What kind of 'port' is 26?  Is that valid on your machine?  My guess is 
that ser is NULL (because the open is failing, likely due to the port 
selection), leading to your subsequent problems.

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


Re: Urgent:Serial Port Read/Write

2013-05-09 Thread MRAB

On 09/05/2013 16:35, chandan kumar wrote:

Hi all,
I'm new to python and facing issue using serial in python.I'm facing the
below error

*ser.write(port,command)*
*NameError: global name 'ser' is not defined*
*
*
Please find the attached script and let me know whats wrong in my script
and also how can i read data from serial port for the  same script.


Best Regards,
Chandan.


RunScripts.py


import time
import os
import serial
import glob


ER_Address = [[0x0A,0x01,0x08,0x99,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB,0xBB]]


Function Name: RunSequence

Function Description:
-
A RunSequence function has Multiple calls to the RunSuite function, each call 
is a single testcase consisting of all the parameters
required by the RunTesSuite.
-

def WriteSerialData(command):


'ser' isn't a local variable (local to this function, that is), nor is
it a global variable (global in this file).


 ser.write(port,command)

def SendPacket(Packet):
 str = chr(len(Packet)) + Packet #Concatenation of Packet with the 
PacketLength
 print str
 WriteSerialData(str)


def CreateFrame(Edata):


It's more efficient to build a list of the characters and then join
them together into a string in one step than to build the string one
character at a time.

Also, indexing into the list is considered 'unPythonic'; it's much 
simpler to do it this way:


return chr(0x12) + .join(chr(d) for d in Edata)


 evt = chr(0x12)
 evt = evt + chr(Edata[0])
 for i in range (1, len(Edata)):
 evt = evt + chr(Edata[i])
 return evt

def SetRequest(data):
 print data
 new = []
 new = sum(data, [])
 Addr = CreateFrame(new)
 SendPacket(Addr)
 print SendPacket Done
 ReadPacket()


def OpenPort(COMPort,BAUDRATE):
 
 This function reads the serial port and writes it.
 
 comport=COMPort
 BaudRate=BAUDRATE
 try:
 ser = serial.Serial(
 port=comport,
 baudrate=BaudRate,
 bytesize=serial.EIGHTBITS,
 parity=serial.PARITY_NONE,
 stopbits=serial.STOPBITS_ONE,
 timeout=10,
 xonxoff=0,
 rtscts=0,
 dsrdtr=0
 )

 if ser.isOpen():
 print Port Opened
 ser.write(Chandan)
 string1 = ser.read(8)
 print string1


This function returns either ser ...


 return ser
 else:
 print Port CLosed
 ser.close()


... or 3 ...

 return 3
 except serial.serialutil.SerialException:
 print Exception
 ser.close()


... or None!






if __name__ == __main__:

 CurrDir=os.getcwd()
 files = glob.glob('./*pyc')
 for f in files:
 os.remove(f)


OpenPort returns either ser or 3 or None, but the result is just
discarded.


 OpenPort(26,9600)
 SetRequest(ER_Address)
 #SysAPI.SetRequest('ER',ER_Address)

 print Test Scripts Execution complete



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


Re: Urgent:Serial Port Read/Write

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 1:35 AM, chandan kumar chandan_...@yahoo.co.in wrote:
 Please find the attached script and let me know whats wrong in my script
 and also how can i read data from serial port for the  same script.

Don't do this:

except serial.serialutil.SerialException:
print Exception
ser.close()

Just let it propagate up and show you a traceback. There is absolutely
no value in suppressing an exception only to print an unhelpful
message.

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


Re: help on Implementing a list of dicts with no data pattern

2013-05-09 Thread rlelis
On Thursday, May 9, 2013 12:47:47 AM UTC+1, rlelis wrote:
@Dave Angel
this is how i mange to read and store the data in file.
data = []
# readdata
f = open(source_file, 'r')
for line in f:
header = (line.strip()).lower()
# conditions(if/else clauses) on the header content to filter desired 
data 
data.append(header)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Style question -- plural of class name?

2013-05-09 Thread Jussi Piitulainen
Neil Cerutti writes:

 If there's no chance for confusion between a class named FooEntry
 and another named FooEntries, then the first attempt seems best.
 Pluralize a class name by following the usual rules, e.g.,
 strings and ints.

Like strings would be foo entries. Which might work well.

(I mean, isn't the class named str?)
-- 
http://mail.python.org/mailman/listinfo/python-list


IV ECCOMAS Thematic Conference VipIMAGE 2013: LAST CALL

2013-05-09 Thread tava...@fe.up.pt
Dear Colleague,

Attending several requests, the organizing committee has extended the 
submission of abstracts for the International Conference VipIMAGE 2013 - IV 
ECCOMAS THEMATIC CONFERENCE ON COMPUTATIONAL VISION AND MEDICAL IMAGE 
PROCESSING (www.fe.up.pt/~vipimage) to be held October 14-16, 2013, in Melia 
Madeira Mare Hotel, Madeira Island, Funchal, Portugal, to May 20th.

Possible Topics (not limited to)

• Signal and Image Processing 
• Computational Vision 
• Medical Imaging 
• Physics of Medical Imaging 
• Tracking and Analysis of Movement 
• Simulation and Modeling
• Image Acquisition 
• Industrial Applications 
• Shape Reconstruction 
• Objects Segmentation, Matching, Simulation 
• Data Interpolation, Registration, Acquisition and Compression 
• 3D Vision 
• Virtual Reality 
• Visual Inspection 
• Software Development for Image Processing and Analysis 
• Computer Aided Diagnosis, Surgery, Therapy, and Treatment 
• Computational Bioimaging and Visualization 
• Telemedicine Systems and their Applications

Invited Lecturers

• Daniel Rueckert - Imperial College London, UK
• Dimitris N. Metaxas - Rutgers University, USA
• Durval C. Costa - Champalimaud Foundation, Portugal
• James S Duncan - Yale School of Medicine, USA
• Milan Sonka - The University of Iowa, USA
• Richard Bowden - University of Surrey, UK

Thematic Sessions

Proposals to organize Thematic Session under the auspicious of VipIMAGE 2013 
are welcome.
The proposals should be submitted by email to the conference co-chairs 
(tava...@fe.up.pt, rna...@fe.up.pt).

Confirmed Thematic Sessions

• Imaging of Biological Flows: trends and challenges
• Trabecular Bone Characterization: New trends and challenges
• Computational Vision and Image Processing applied to Dental Medicine

Publications

• Proceedings: The proceedings book will be published by the Taylor  Francis 
Group (www.balkema.nl/instructions.asp) and indexed by Thomson Reuters 
Conference Proceedings Citation Index, IET Inspect and Elsevier Scopus.
• Springer Book: A book with 20 invited works from the ones presented in the 
conference will be published by Springer under the book series “Lecture Notes 
in Computational Vision and Biomechanics” (www.springer.com/series/8910).
• Journal Publication: A dedicated special issue of the Taylor  Francis 
International Journal “Computer Methods in Biomechanics and Biomedical 
Engineering: Imaging  Visualization” (www.tandfonline.com/tciv) will be 
published with extended versions of the best works presented in the conference.

Important dates

• Deadline for (2-4 pages) Abstracts: May 20, 2013 (LAST POSTPONED)
• Authors Notification: June 10, 2013
• Deadline to upload Lectures and Papers: July 1, 2013


We are looking forward to see you in Funchal next October.

Kind regards,

João Manuel R. S. Tavares
Renato Natal Jorge
(conference co-chairs)

PS. For further details, please, have a look in the conference website at: 
www.fe.up.pt/~vipimage, or in the conference Facebook page at: 
www.facebook.com/pages/Vipimage/237980719665456, or join the LinkedIn 
conference group at: http://www.linkedin.com/groups?gid=4752820trk=hb_side_g
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Style question -- plural of class name?

2013-05-09 Thread Neil Cerutti
On 2013-05-09, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote:
 Neil Cerutti writes:
 If there's no chance for confusion between a class named
 FooEntry and another named FooEntries, then the first attempt
 seems best. Pluralize a class name by following the usual
 rules, e.g., strings and ints.

 Like strings would be foo entries. Which might work well.

 (I mean, isn't the class named str?)

Yeah, that's not such a good Python example. I used it to replace
chars and felt good at the time. ;)

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


Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Ian Kelly
On Wed, May 8, 2013 at 8:35 PM, Mark Janssen dreamingforw...@gmail.com wrote:
 Okay, to anyone who might be listening, I found the core of the problem.

What problem are you referring to?  You've been posting on this
topic for going on two months now, and I still have no idea of what
the point of it all is.  I recall something about not being happy with
the OOP paradigm because apparently none of the dozens of existing
languages handle message passing in the particular way that you think
it should work; but if that's all it is, then why don't you just build
a new language that does it the way that you think is right?  If it's
good, spread it around and it will gain traction.  If not, then it
will die the quiet death it deserves.  All this irrelevant nonsense
about Turing machines and lambda calculus that you've injected into
the conversation though just reminds me of the Einstein was wrong
cranks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Style question -- plural of class name?

2013-05-09 Thread Robert Kern

On 2013-05-08 21:20, Roy Smith wrote:

FooEntry is a class.  How would you describe a list of these in a
docstring?

A list of FooEntries

A list of FooEntrys

A list of FooEntry's

A list of FooEntry instances

The first one certainly sounds the best, but it seems wierd to change
the spelling of the class name to make it plural.


I'm using services like Github more and more to talk about code, so I have taken 
to adopting its inline markup for `code` when referring to identifiers. Thus, I 
will often write


  A list of `FooEntry`s

But I don't mind

  A list of FooEntries

Hopefully there isn't also a `FooEntries` class.

--
Robert Kern

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

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


Re: help on Implementing a list of dicts with no data pattern

2013-05-09 Thread Dave Angel

On 05/09/2013 12:14 PM, rlelis wrote:

On Thursday, May 9, 2013 12:47:47 AM UTC+1, rlelis wrote:
@Dave Angel
this is how i mange to read and store the data in file.
data = []
# readdata
f = open(source_file, 'r')
for line in f:
 header = (line.strip()).lower()
 # conditions(if/else clauses) on the header content to filter desired 
data
 data.append(header)



From earlier message:
 highway_dict = {}
 aging_dict = {}
 queue_counters={}
 queue_row = []
 for content in file_content:
if 'aging' in content:

So your data is a list of strings, each representing one line of the 
file.  When you run this, you'll get something like:


NameError: name 'file_content' is not defined

If I assume you've just neglected to include the assignment, 
file_content = data, then the next problem is


 if 'aging' in content:

will never fire.  Likewise
if 'highway' in content:

will never fire.  So the rest of the code is irrelevant.

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


Re: object.enable() anti-pattern

2013-05-09 Thread Steven D'Aprano
On Thu, 09 May 2013 09:07:42 -0400, Roy Smith wrote:

 In article 518b32ef$0$11120$c3e8...@news.astraweb.com,
  Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
  
 There is no sensible use-case for creating a file without opening it.
 
 Sure there is.  Sometimes just creating the name in the file system is
 all you want to do.  That's why, for example, the unix touch command
 exists.

Since I neglected to make it clear above that I was still talking about 
file objects, rather than files on disk, I take responsibility for this 
misunderstanding. I thought that since I kept talking about file 
*objects* and *constructors*, people would understand that I was talking 
about in-memory objects rather than on-disk files. Mea culpa.

So, let me rephrase that sentence, and hopefully clear up any further 
misunderstandings.

There is no sensible use-case for creating a file OBJECT unless it 
initially wraps an open file pointer.

This principle doesn't just apply to OOP languages. The standard C I/O 
library doesn't support creating a file descriptor unless it is a file 
descriptor to an open file. open() has the semantics:

It shall create an open file description that refers to a file and a 
file descriptor that refers to that open file description.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html

and there is no corresponding function to create a *closed* file 
description. (Because such a thing would be pointless.)

Of course language designers are free to design their language to work 
under whatever anti-patterns they desire. I quote from the Pascal 
Language Reference:

open associates the permanent file file [sic] with a file variable for 
reading or writing. open does not actually open the file; you must call 
reset or rewrite before reading or writing to that file.

http://www.amath.unc.edu/sysadmin/DOC4.0/pascal/lang_ref/
ref_builtin.doc.html


but since that's not a part of standard Pascal, other Pascals may behave 
differently.



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


Re: object.enable() anti-pattern

2013-05-09 Thread MRAB

On 09/05/2013 19:21, Steven D'Aprano wrote:

On Thu, 09 May 2013 09:07:42 -0400, Roy Smith wrote:


In article 518b32ef$0$11120$c3e8...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:


There is no sensible use-case for creating a file without opening it.


Sure there is.  Sometimes just creating the name in the file system is
all you want to do.  That's why, for example, the unix touch command
exists.


Since I neglected to make it clear above that I was still talking about
file objects, rather than files on disk, I take responsibility for this
misunderstanding. I thought that since I kept talking about file
*objects* and *constructors*, people would understand that I was talking
about in-memory objects rather than on-disk files. Mea culpa.

So, let me rephrase that sentence, and hopefully clear up any further
misunderstandings.

There is no sensible use-case for creating a file OBJECT unless it
initially wraps an open file pointer.


You might want to do this:

f = File(path)
if f.exists():
...

This would be an alternative to:

if os.path.exists(path):
...


This principle doesn't just apply to OOP languages. The standard C I/O
library doesn't support creating a file descriptor unless it is a file
descriptor to an open file. open() has the semantics:

It shall create an open file description that refers to a file and a
file descriptor that refers to that open file description.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html

and there is no corresponding function to create a *closed* file
description. (Because such a thing would be pointless.)


[snip]

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


Re: Help with implementing callback functions using ctypes

2013-05-09 Thread Nobody
On Wed, 08 May 2013 04:19:07 -0700, jamadagni wrote:

 I have the below C program spiro.c (obviously a simplified testcase)
 which I compile to a sharedlib using clang -fPIC -shared -o libspiro.so
 spiro.c, sudo cp to /usr/lib and am trying to call from a Python script
 spiro.py using ctypes. However it would seem that the first call to the
 callback results in a segfault.

 # call the C function
 spiro_to_bezier_strict ( src, len ( src ), bc )

This line should be:

  spiro_to_bezier_strict ( src, len ( src ), byref(bc) )

Without the byref(...), it will try to pass a copy of the structure rather
than passing a pointer to it.

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


Re: object.enable() anti-pattern

2013-05-09 Thread Roy Smith
In article 518be931$0$29997$c3e8da3$54964...@news.astraweb.com,
Steven D'Aprano  steve+comp.lang.pyt...@pearwood.info wrote:
 There is no sensible use-case for creating a file OBJECT unless it 
 initially wraps an open file pointer.

OK, I guess that's a fair statement.  But mostly because a python file
object only exposes those subset of operations you can do on file
descriptors which deal with reading and writing the contents of a
file.

It would not be true if python file objects included methods for
querying and manipulating file metadata.  It's not hard to imagine a
file class which could be used like:

f = file(/path/to/my/file)
f.delete()

That would be a totally different model from the current python file
object.  And then there would be plenty of things you might want to do
to a file other than open it...

file(/path/to/my/directory).chdir()
file(/dev/sdf).mount(/var/lib/whatever)
file(/mnt/swapfile).swapon()

 The standard C I/O library doesn't support creating a file
 descriptor unless it is a file descriptor to an open file [...]
 there is no corresponding function to create a *closed* file
 description. (Because such a thing would be pointless.)

What about sockets?  From the python standard library:

s = socket.socket()

Now what?  You can't do much with your shiny new socket until you call
bind() or connect(), or a few other things.  At least not for TCP.
This is essentially the two-phased construction pattern.  Of course,
the python socket module just exposes the semantics of the underlying
OS sockets, so there's not a lot of choice there.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help on Implementing a list of dicts with no data pattern

2013-05-09 Thread rlelis
On Thursday, May 9, 2013 7:19:38 PM UTC+1, Dave Angel wrote:

Yes it's a list of string. I don't get the NameError: name 'file_content' is 
not defined in my code.

After i appended the headers i wanted to cut the data list it little bit more 
because there was some data (imagine some other collumns) to the left that 
didn't needed.

file_content = []
for d in data:
file_content.append(d[1:])

from this point on i've showed the code,
highway_dict = {} 
aging_dict = {} 
queue_counters={} 
queue_row = [] 
for content in file_content: 
if 'aging' in content: 
# aging 0 100
# code here
 
etc, etc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Mark Janssen
  These models of computation should not use the same language.  Their
 computation models are too radically different.

 Their computation models are exactly equivalent.

No they are not.  While one can find levels of indirection to
translate between one and the other, that doesn't mean they're
equivalent.  It's like saying that because I can make an equivalence
between the complex plane and the real, that they should be treated as
equivalent.  But they shouldn't -- else you run into a domain error.

-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Mark Janssen
On Thu, May 9, 2013 at 10:33 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Wed, May 8, 2013 at 8:35 PM, Mark Janssen dreamingforw...@gmail.com 
 wrote:
 Okay, to anyone who might be listening, I found the core of the problem.

 What problem are you referring to?  You've been posting on this
 topic for going on two months now, and I still have no idea of what
 the point of it all is.

You see Ian, while you and the other millions of coding practitioners
have (mal)adapted to a suboptimal coding environment where hey
there's a language for everyone  and terms are thrown around,
misused, this is not how it needs or should be.  Instead of the
thriving Open Source culture on the web we could have, the community
stays fractured.   Languages can reach for an optimal design (within a
constant margin of leeway).   Language expressivity can be measured.

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


Re: object.enable() anti-pattern

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 4:59 AM, Roy Smith r...@panix.com wrote:
 It's not hard to imagine a
 file class which could be used like:

 f = file(/path/to/my/file)
 f.delete()

 That would be a totally different model from the current python file
 object.  And then there would be plenty of things you might want to do
 to a file other than open it...

 file(/path/to/my/directory).chdir()
 file(/dev/sdf).mount(/var/lib/whatever)
 file(/mnt/swapfile).swapon()

Sure, you can imagine it. But what does it do that can't be done with
a moduleful of flat functions accepting strings? This makes sense in
Java, I guess, but why do it in Python?

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


Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Ian Kelly
On Thu, May 9, 2013 at 3:51 PM, Mark Janssen dreamingforw...@gmail.com wrote:
 On Thu, May 9, 2013 at 10:33 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Wed, May 8, 2013 at 8:35 PM, Mark Janssen dreamingforw...@gmail.com 
 wrote:
 Okay, to anyone who might be listening, I found the core of the problem.

 What problem are you referring to?  You've been posting on this
 topic for going on two months now, and I still have no idea of what
 the point of it all is.

 You see Ian, while you and the other millions of coding practitioners
 have (mal)adapted to a suboptimal coding environment where hey
 there's a language for everyone  and terms are thrown around,
 misused, this is not how it needs or should be.  Instead of the
 thriving Open Source culture on the web we could have,

Non sequitur.  Open source software has nothing to do with coding
environment or choice of language or OOP paradigm.  Or Turing machines
or lambda calculus, for that matter.

 the community stays fractured.

The open source community seems pretty healthy to me.  What is the
basis of your claim that it is fractured?

 Languages can reach for an optimal design (within a constant margin of 
 leeway).

There is no optimal design.  The *reason* that there's a language
for everyone is because different people think about software in
different ways and find different approaches better suited to them.
Furthermore, some programming styles are naturally more conducive to
accomplishing certain tasks, and worse at others.  Take video game
programming for an example.  If I'm working on the graphics engine for
a game, I would probably want to use a low-level imperative language
for efficiency reasons.  If I'm working on the AI, I will more likely
prefer a functional or declarative language for clarity, flexibility
and static analysis.  In either case, OOP is probably a bad choice.

 Language expressivity can be measured.

And the measurements can be endlessly debated.  Expressivity is not
the sole measure of a programming language, though.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help on Implementing a list of dicts with no data pattern

2013-05-09 Thread Dave Angel

On 05/09/2013 05:22 PM, rlelis wrote:

On Thursday, May 9, 2013 7:19:38 PM UTC+1, Dave Angel wrote:

Yes it's a list of string. I don't get the NameError: name 'file_content' is 
not defined in my code.


That's because you have the 3 lines below which we hadn't seen yet.



After i appended the headers i wanted to cut the data list it little bit more 
because there was some data (imagine some other collumns) to the left that 
didn't needed.

file_content = []
for d in data:
 file_content.append(d[1:])

from this point on i've showed the code,
highway_dict = {}
aging_dict = {}
queue_counters={}
queue_row = []
for content in file_content:
 if 'aging' in content:
 # aging 0 100
 # code here



OK, so I now have some code I can actually run.  Unfortunately, it 
produces an error:


Traceback (most recent call last):
  File ricardo.py, line 23, in module
aging_dict['total'], aging_dict[columns] = total, aging_values
NameError: name 'total' is not defined

So I'll make a reasonable guess that you meant total_values there.  I 
still can't understand how you're testing this code, when there are 
trivial bugs in it.


Next, I get:

Traceback (most recent call last):
  File ricardo.py, line 32, in module
highway_dict['lanes'], highway_dict['state'], 
highway_dict['limit(mph)'] = lanes, state, limit_values

NameError: name 'lanes' is not defined

and then:

Traceback (most recent call last):
  File ricardo.py, line 32, in module
highway_dict['lanes'], highway_dict['state'], 
highway_dict['limit(mph)'] = lanes_values, state, limit_values

NameError: name 'state' is not defined

Each of those not-defined errors was pointed out by me earlier in the 
thread.


I don't see any output logic, so I guess it's up to us to guess what the 
meanings and scope of the various lists and dicts are.  I figure the 
queue_row is your final collection that you hope to get results from. 
It's a list containing many references to a single queue_counters 
object.  So naturally, they all look the same.


If you want them to be different, you have to create a new one each 
time.  Move the line:

queue_counters={}

inside the loop, right after the line:
for content in file_content:

There are a bunch of other things wrong, like not lining up the columns 
when you're substringing content, but this may be your major stumbling 
block.  Note:  you may have to also move the highway_dict and 
aging_dict;  I haven't figured out what they're for, yet.


Following is the code I've been using to try to figure out what you were 
intending:



file_content = [
aging 0 100,
aging 2 115,
aging 3 1,
highway 4 disable 25,
highway 2 disable 245,
highway 0 enable 125,
]

highway_dict = {}
aging_dict = {}
#queue_counters={}
queue_row = []
for content in file_content:
queue_counters={}
if 'aging' in content:
# aging 0 100
columns = ', '.join(map(str, 
content[:1])).replace('-','_').lower()

print columns:, columns
total_values =''.join(map(str, content[1:2]))
aging_values = '\t'.join(map(str, content[2:]))

aging_dict['total'], aging_dict[columns] = 
total_values, aging_values

queue_counters[columns] = aging_dict
if 'highway' in content:
#highway|   4   |   disable |   25
columns = ''.join(map(str, 
content[:1])).replace('-','_').lower()

lanes_values  =''.join(map(str, content[1:2]))
state_values = ''.join(map(str, content[2:3])).strip('')
limit_values = ''.join(map(str, content[3:4])).strip('')

highway_dict['lanes'], highway_dict['state'], 
highway_dict['limit(mph)'] = lanes_values, state_values, limit_values

queue_counters[columns] = highway_dict
queue_row.append(queue_counters)


print
print h dict:, highway_dict
print
print aging dict:, aging_dict
print
print q counters:, queue_counters
for key, item in  queue_counters.iteritems():
print key, item

print
print q row:, queue_row
for item in queue_row:
print item






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


Re: object.enable() anti-pattern

2013-05-09 Thread Greg Ewing

Cameron Simpson wrote:

You open a file with 0 modes, so
that it is _immediately_ not writable. Other attempts to make the
lock file thus fail because of the lack of write,


I don't think that's quite right. You open it with
O_CREAT+O_EXCL, which atomically fails if the file
already exists. The read/write modes don't really
come into it, as far as I know.

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


Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 8:30 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, May 9, 2013 at 3:51 PM, Mark Janssen dreamingforw...@gmail.com 
 wrote:
 the community stays fractured.

 The open source community seems pretty healthy to me.  What is the
 basis of your claim that it is fractured?

The carpentry community is fractured. There are people who use
screwdrivers, and there are people who use hammers! Screws and nails
are such completely different things that we shouldn't try to use the
same language to discuss them.

 Language expressivity can be measured.

 And the measurements can be endlessly debated.  Expressivity is not
 the sole measure of a programming language, though.

Every programming language can encode every program. It's fairly
straightforward to prove that a Python interpreter can be written in
Ruby, or a C interpreter in Lua; so there is no program that can be
expressed in one language and not in another (there will be apparent
exceptions, eg web-browser JavaScript cannot call on arbitrary C-level
functionality, but if the entirety of program code were written in C,
then it could all be interpreted by one C interpreter).

Larry Wall of Perl put it this way, in a State of the Onion address:

http://www.perl.com/pub/2007/12/06/soto-11.html
... Human languages are Turing complete, as it were.

Human languages therefore differ not so much in what you can say but
in what you must say. In English, you are forced to differentiate
singular from plural. In Japanese, you don't have to distinguish
singular from plural, but you do have to pick a specific level of
politeness, taking into account not only your degree of respect for
the person you're talking to, but also your degree of respect for the
person or thing you're talking about.

So languages differ in what you're forced to say. Obviously, if your
language forces you to say something, you can't be concise in that
particular dimension using your language. Which brings us back to
scripting.

How many ways are there for different scripting languages to be concise?


In C, for example, you are forced to write explicit notation
representing {blocks; of; code;} and explicit characters separating;
statements;. In Python, on the other hand, you have to write out your
indentation. In Java, you state what exceptions you might throw. REXX
mandates that you annotate procedures with their list of exposed names
(effectively, non-local and global variables). So the expressivity of
a language can't be defined in terms of how many programs can be
written in it, but in how concisely they can be written - and that's
something that depends on specific design choices and how they align
with the code you're trying to write.

Compare these two snippets:

#!/bin/sh
pg_dumpall | gzip | ssh user@host 'gzip -d|psql'

#!/usr/bin/env python
words=input(Enter words, blank delimited: )
lengths=[len(x) for x in words.split( )]
print(Average word length: %d%int(sum(lengths)/len(lengths)))

Could you write each in the other's language? Sure! But it won't be as
concise. (The Python version of the shell script could cheat and just
call on the shell to do the work, but even that would add the
expressive overhead of os.system.) This is why there are so many
languages: because each is good at something different.

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


[ANN] flask-canvas

2013-05-09 Thread Demian Brecht
A Flask extension for Facebook canvas-based applications.

https://github.com/demianbrecht/flask-canvas

Docs available on RTD: https://flask-canvas.readthedocs.org/en/latest/

--
Demian Brecht
http://demianbrecht.github.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object.enable() anti-pattern

2013-05-09 Thread Cameron Simpson
On 09May2013 11:30, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 
wrote:
| On Thu, 09 May 2013 18:23:31 +1000, Cameron Simpson wrote:
| 
|  On 09May2013 19:54, Greg Ewing greg.ew...@canterbury.ac.nz wrote:
|  | Steven D'Aprano wrote:
|  |  There is no sensible use-case for creating a file WITHOUT OPENING
|  |  it. What would be the point?
|  |
|  | Early unix systems often used this as a form of locking.
|  
|  Not just early systems: it's a nice lightweight method of making a
|  lockfile even today if you expect to work over NFS, where not that many
|  things are synchronous. You OPEN A FILE with 0 modes
| 
| [emphasis added]
| This is all very well and good, but for the life of me, I cannot see how 
| opening a file is a good example of not opening a file. Perhaps it is a 
| Zen thing, like the sound no spoon makes when you don't tap it against a 
| glass that isn't there.

Because a file usually does not exist in isolation (yes sometimes
we want an isolated file). Files usually exist in the filesystem,
which is a namespace. And this is effectively a namespace operation,
not a data storage operation.

Of course, I can take this the other way: just because I opened it
with a 0 mode field doesn't mean _I_, the opener, cannot read/write
it. I've got an open file handle... A race free way to make a scratch
file in a shared area, for example.

The point is probably that a file isn't merely a feature free byte
storage container; in the real world they usually come with all
sorts of features like names and permissions. Those features will
always imply creative uses.

Anyway, this has little to do with your antipattern (about which
I'm not totally convinced anyway unless it is a rule of thumb or
code smell). It might apply to a Platonicly ideal file, but real
files have more than one use case.

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

I just kept it wide-open thinking it would correct itself.
Then I ran out of talent.   - C. Fittipaldi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object.enable() anti-pattern

2013-05-09 Thread Gregory Ewing

Wayne Werner wrote:
You don't ever want a class that has functions that need to be called in 
a certain order to *not* crash.


That seems like an overly broad statement. What
do you think the following should do?

   f = open(myfile.dat)
   f.close()
   data = f.read()

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


Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread alex23
On 10 May, 03:33, Ian Kelly ian.g.ke...@gmail.com wrote:
 You've been posting on this
 topic for going on two months now, and I still have no idea of what
 the point of it all is.

As Charlie Brooker put it: almost every monologue consists of nothing
but the words PLEASE AUTHENTICATE MY EXISTENCE, repeated over and over
again, in disguise.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread alex23
On 10 May, 07:51, Mark Janssen dreamingforw...@gmail.com wrote:
 You see Ian, while you and the other millions of coding practitioners
 have (mal)adapted to a suboptimal coding environment where hey
 there's a language for everyone  and terms are thrown around,
 misused, this is not how it needs or should be.

Please cite your industry experience so we know this is a pragmatic
exercise for you and not a display of public onanism.

 Instead of the
 thriving Open Source culture on the web we could have, the community
 stays fractured.

What fractures communities is telling millions of [maladapted]
practitioners that they're wrong, and that your unsubstantiated
intuition somehow trumps their billions of hours of combined
experience.

 Languages can reach for an optimal design (within a
 constant margin of leeway).   Language expressivity can be measured.

I'm sure that's great. I, however, have a major project going live in
a few weeks and would rather just get something done.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object.enable() anti-pattern

2013-05-09 Thread Cameron Simpson
On 10May2013 10:56, Greg Ewing greg.ew...@canterbury.ac.nz wrote:
| Cameron Simpson wrote:
| You open a file with 0 modes, so
| that it is _immediately_ not writable. Other attempts to make the
| lock file thus fail because of the lack of write,
| 
| I don't think that's quite right. You open it with
| O_CREAT+O_EXCL, which atomically fails if the file
| already exists. The read/write modes don't really
| come into it, as far as I know.

Interesting. That is more direct. My understanding that it was
enough to create the file with 0 modes. Maybe either will do. Must
check...

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

Piracy gets easier every day, but listening to legally purchased music gets 
harder by the day.
Firehed - http://politics.slashdot.org/comments.pl?sid=179175cid=14846089
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-09 Thread Gregory Ewing

Roy Smith wrote:

In article 518b133b$0$29997$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

I suspect that the only way to be completely ungoogleable would be to 
name yourself something common, not something obscure.


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


Nope... googling for the band brings that up as the
very first result.

The Google knows all. You cannot escape The Google...

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


Re: object.enable() anti-pattern

2013-05-09 Thread Michael Speer
By his reasoning it simply shouldn't exist. Instead you would access the
information only like this:

with open(myfile.dat) as f:
  data = f.read()

Which is my preferred way to work with resources requiring cleanup in
python anyways, as it ensures I have the least chance of messing things up,
and that all of my resources are disposed of properly during the unwind.
It's a hell of a lot cleaner than remembering to call the appropriate
cleanup functions at every callsite, and the resultant values can never be
in a bad state ( at least due to programmer function-ordering fault,
underlying file i/o errors and things can still cause errors, but not due
to API mis-usage ).

Python 3's multiple-with-statement-target syntax was backported to 2.7 as
well, flattening the deep nests of with statements otherwise needed to
implement this pattern
http://docs.python.org/dev/whatsnew/2.7.html#other-language-changes

On Thu, May 9, 2013 at 7:43 PM, Gregory Ewing
greg.ew...@canterbury.ac.nzwrote:

 Wayne Werner wrote:

 You don't ever want a class that has functions that need to be called in
 a certain order to *not* crash.


 That seems like an overly broad statement. What
 do you think the following should do?

f = open(myfile.dat)
f.close()
data = f.read()


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

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


Re: object.enable() anti-pattern

2013-05-09 Thread Roy Smith
In article mailman.1514.1368145123.3114.python-l...@python.org,
 Michael Speer knome...@gmail.com wrote:

 By his reasoning it simply shouldn't exist. Instead you would access the
 information only like this:
 
 with open(myfile.dat) as f:
   data = f.read()

The problem with things like file objects is they model external 
real-world entities, which have externally-imposed real-world behaviors.

f.close() can fail, most commonly because some buffered output couldn't 
be written when being flushed as part of the close().  Sometimes it's 
important to find out about that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-09 Thread Tim Chase
On 2013-05-10 12:04, Gregory Ewing wrote:
 Roy Smith wrote:
  http://en.wikipedia.org/wiki/The_band
 
 Nope... googling for the band brings that up as the
 very first result.
 
 The Google knows all. You cannot escape The Google...

That does it.  I'm naming my band Google. :-)

-tkc


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


python call golang

2013-05-09 Thread Thanatos xiao
Hey !

Now! I have written a python script . I want to call a golang script in
python script.
Who can give me some advices?

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


Re: object.enable() anti-pattern

2013-05-09 Thread Steven D'Aprano
On Thu, 09 May 2013 19:34:25 +0100, MRAB wrote:

 There is no sensible use-case for creating a file OBJECT unless it
 initially wraps an open file pointer.

 You might want to do this:
 
 f = File(path)
 if f.exists():
  ...
 
 This would be an alternative to:
 
 if os.path.exists(path):
  ...

Sure, but your made-up File object does not represent a file, it 
represents a pathname which *may or may not* exist. Pathnames are not 
files. Not all files have a pathname that refers to them, and not all 
pathnames point to an actual file. Since it has an exists() method that 
can return False, there are so-called File objects that aren't files 
and the name is a misnomer. A much better name for the class would be 
Path, not File.

I'm not saying that there is never a use-case for some objects to have an 
enable or start or open method. That would clearly be a silly thing 
to say. In the real world, we design many objects to have a start switch. 
It would be pretty horrible if your car was running all the time. But 
that's because there are actual use-cases for having cars *not* run, and 
make it stop is the safe default behaviour.

Your fridge, on the other hand, doesn't have a make it go button. So 
long as power is applied to it, your fridge automatically runs. Likewise, 
your watch is an always on device, provided it hasn't wound down or 
have a flat battery. Your fire alarm is always on. 

I must admit I am astonished at how controversial the opinion if your 
object is useless until you call 'start', you should automatically call 
'start' when the object is created has turned out to be.



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


Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 9:58 AM, alex23 wuwe...@gmail.com wrote:
 On 10 May, 07:51, Mark Janssen dreamingforw...@gmail.com wrote:
 Languages can reach for an optimal design (within a
 constant margin of leeway).   Language expressivity can be measured.

 I'm sure that's great. I, however, have a major project going live in
 a few weeks and would rather just get something done.

Hmm, not really a fair argument there. A well-designed language lets
you just get something done far more efficiently than a
poorly-designed one. Being confident that similar objects behave
correspondingly when invoked the same way lets you write your code
without fiddling with minutiae, for instance. (Hmm, I'll just switch
that from being a tuple to being a list, so I can modify this one
element. - code that indexes or iterates won't be affected.)

Now, whether or not it's worth _debating_ the expressiveness of a
language... well, that's another point entirely. But for your major
project, I think you'll do better working in Python than in machine
code.

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


Re: object.enable() anti-pattern

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 12:30 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 I must admit I am astonished at how controversial the opinion if your
 object is useless until you call 'start', you should automatically call
 'start' when the object is created has turned out to be.

I share your astonishment. This is a very simple point: If, after
constructing an object, the caller MUST call some method on it prior
to the object being of use, then better design is to embed that call
directly into the constructor. As always, it has its exceptions, but
that doesn't stop it being a useful rule.

The Path() equivalent would be:

p = Path()
p.set_path(/foo/bar)
if p.exists():
  pass

Even if you have a set_path() method, it makes good sense to symlink
it to __init__ to avoid this anti-pattern.

C level APIs often have these sorts of initialization requirements.

fd_set selectme;
FD_ZERO(selectme);

This is because declaring a variable in C cannot initialize it.
Anything that *has* constructors should be using them to set objects
up... that's what they're for.

Where's the controversy?

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


Re: object.enable() anti-pattern

2013-05-09 Thread Roy Smith
In article 518c5bbc$0$29997$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 I must admit I am astonished at how controversial the opinion if your 
 object is useless until you call 'start', you should automatically call 
 'start' when the object is created has turned out to be.

I'm sorry.  I thought you were here for an argument.

I think where things went pear shaped is when you made the statement:

 There is no sensible use-case for creating a file OBJECT unless it
 initially wraps an open file pointer.

That's a pretty absolute point of view.  Life is rarely so absolute.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Mark Janssen
On Thu, May 9, 2013 at 4:58 PM, alex23 wuwe...@gmail.com wrote:
 On 10 May, 07:51, Mark Janssen dreamingforw...@gmail.com wrote:
 You see Ian, while you and the other millions of coding practitioners
 have (mal)adapted to a suboptimal coding environment where hey
 there's a language for everyone  and terms are thrown around,
 misused, this is not how it needs or should be.

 Please cite your industry experience so we know this is a pragmatic
 exercise for you and not a display of public onanism.

Industry experience

Do you know all the world's [industrial] leaders are endorsing an
impossible path of endless, exponential growth on a finite planet?

Is that who you answer to?

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


Re: object.enable() anti-pattern

2013-05-09 Thread Mark Janssen
 I think where things went pear shaped is when you made the statement:

 There is no sensible use-case for creating a file OBJECT unless it
 initially wraps an open file pointer.

 That's a pretty absolute point of view.  Life is rarely so absolute.

In the old days, it was useful to have fine-grained control over the
file object because you didn't know where it might fail, and the OS
didn't necessarily give you give good status codes.  So being able to
step through the entire process was the job of the progammers.

Now, with languages so high like python and hardware so common, it
almost is never necessary, so he has some point.   A closed file
pointer is useful from a OS-progamming point-of-view though because
you generally never want to leave files open where they'd block other
I/O.


-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object.enable() anti-pattern

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 1:19 PM, Mark Janssen dreamingforw...@gmail.com wrote:
 I think where things went pear shaped is when you made the statement:

 There is no sensible use-case for creating a file OBJECT unless it
 initially wraps an open file pointer.

 That's a pretty absolute point of view.  Life is rarely so absolute.

 In the old days, it was useful to have fine-grained control over the
 file object because you didn't know where it might fail, and the OS
 didn't necessarily give you give good status codes.  So being able to
 step through the entire process was the job of the progammers.

I don't know what you mean by the old days, but a couple of decades
ago, there were no such things as file objects. You call a function
to open a file, you get back a number. You explicitly close that by
calling another function and passing it that number. In fact, there is
no way to have a file object that doesn't have an open file
associated with it, because it's simply... a number.

 Now, with languages so high like python and hardware so common, it
 almost is never necessary, so he has some point.   A closed file
 pointer is useful from a OS-progamming point-of-view though because
 you generally never want to leave files open where they'd block other
 I/O.

I'm beginning to wonder if you and Dihedral are swapping notes.
Dihedral's been sounding fairly coherent lately.

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


Re: Message passing syntax for objects | OOPv2

2013-05-09 Thread Chris Angelico
On Fri, May 10, 2013 at 1:08 PM, Mark Janssen dreamingforw...@gmail.com wrote:
 On Thu, May 9, 2013 at 4:58 PM, alex23 wuwe...@gmail.com wrote:
 On 10 May, 07:51, Mark Janssen dreamingforw...@gmail.com wrote:
 You see Ian, while you and the other millions of coding practitioners
 have (mal)adapted to a suboptimal coding environment where hey
 there's a language for everyone  and terms are thrown around,
 misused, this is not how it needs or should be.

 Please cite your industry experience so we know this is a pragmatic
 exercise for you and not a display of public onanism.

 Industry experience

 Do you know all the world's [industrial] leaders are endorsing an
 impossible path of endless, exponential growth on a finite planet?

 Is that who you answer to?

I don't answer to them. I also believe in a path of endless
exponential growth. Challenge: Create more information than can be
stored in one teaspoon of matter. Go ahead. Try!

The first hard disk I ever worked with stored 20MB in the space of a
5.25 slot (plus its associated ISA controller card). Later on we got
3.5 form factor drives, and I remember installing this *gigantic*
FOUR GIGABYTE drive into our disk server. Wow! We'll NEVER use all
that space! (Well, okay. Even then we knew that space consumption kept
going up. But we did figure on that 4GB lasting us a good while, which
it did.) Today, I can pop into Budget PC or MSY (or you folks in the
US could check out newegg) and pick up a terabyte of storage in the
same amount of physical space, or you can go 2.5 form factor and take
up roughly a fifth of the physical space and still get half a terabyte
fairly cheaply. So our exponential growth is being supported by
exponential increases in data per cubic meter. Between that and the
vast size of this planet, I don't think we really need to worry too
much about finite limits to IT growth.

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


Re: Message passing syntax for objects | OOPv2

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

 The first hard disk I ever worked with stored 20MB in the space of a
 5.25 slot (plus its associated ISA controller card).

Heh.  The first hard disk I ever worked with stored 2.4 MB in 6U of rack 
space (plus 4 Unibus cards worth of controller).  That's not actually 
the first hard disk I ever used.  Just the first one I ever got to touch 
with my own hands.

Did I mention that the air filters had to be changed a few times a year?
  
Uphill both ways, in the snow, while beating off the dinosaurs with 
sticks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: object.enable() anti-pattern

2013-05-09 Thread Steven D'Aprano
On Thu, 09 May 2013 23:09:55 -0400, Roy Smith wrote:

 In article 518c5bbc$0$29997$c3e8da3$54964...@news.astraweb.com,
  Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 
 I must admit I am astonished at how controversial the opinion if your
 object is useless until you call 'start', you should automatically call
 'start' when the object is created has turned out to be.
 
 I'm sorry.  I thought you were here for an argument.

No, I'm here for the abuse.


 I think where things went pear shaped is when you made the statement:
 
 There is no sensible use-case for creating a file OBJECT unless it
 initially wraps an open file pointer.
 
 That's a pretty absolute point of view.  Life is rarely so absolute.

So far the only counter-examples given aren't counter-examples. One 
involves opening the file. The other involves something which isn't a 
file, but a string instead. If there are any counter-examples, they are 
impossible in Python and C: you cannot create a file object in Python 
without opening it, and you cannot create a file descriptor in C without 
opening it. But not in Pascal, which actually supports my claim that this 
is an anti-pattern: while some Pascal implementations do allow you to 
create a non-open file, you cannot do *anything* with it until you open 
it, except generate bugs.



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


Re: object.enable() anti-pattern

2013-05-09 Thread Steven D'Aprano
On Fri, 10 May 2013 09:36:43 +1000, Cameron Simpson wrote:

 On 09May2013 11:30, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote: 
 | On Thu, 09 May 2013 18:23:31 +1000, Cameron Simpson wrote: 
 |
 |  On 09May2013 19:54, Greg Ewing greg.ew...@canterbury.ac.nz wrote:
 |  | Steven D'Aprano wrote:
 |  |  There is no sensible use-case for creating a file WITHOUT
 |  |  OPENING it. What would be the point?
 |  |
 |  | Early unix systems often used this as a form of locking. 
 | 
 |  Not just early systems: it's a nice lightweight method of making a
 |  lockfile even today if you expect to work over NFS, where not that
 |  many things are synchronous. You OPEN A FILE with 0 modes 
 | [emphasis added]

 | This is all very well and good, but for the life of me, I cannot see
 | how opening a file is a good example of not opening a file. Perhaps it
 | is a Zen thing, like the sound no spoon makes when you don't tap it
 | against a glass that isn't there.
 
 Because a file usually does not exist in isolation (yes sometimes we
 want an isolated file). Files usually exist in the filesystem, which is
 a namespace. And this is effectively a namespace operation, not a data
 storage operation.

 Of course, I can take this the other way: just because I opened it with
 a 0 mode field doesn't mean _I_, the opener, cannot read/write it. I've
 got an open file handle... A race free way to make a scratch file in a
 shared area, for example.


But you are opening the file. Therefore, it cannot possibly be an example 
of not opening the file.

Unlike Pascal, there is no way to create a C file descriptor in a closed 
state. Such a thing does not exist. If you have a file descriptor, the 
file is open. Once you close it, the file descriptor is no longer valid.

But even if C allowed you to do so, doesn't mean that it is a good idea. 
At least some variants of Pascal force you to do the following:

# Pseudo-code.
f = open(filename)
really_open(f)
data = read(f)  # or write, or *any other operation at all*

Surely we can agree that having to call both open() and really_open() 
before you get an actually opened file that you can use is one call too 
many? There is *nothing* you can do with f before calling really_open(). 
So why require it?

(For the record, really_open is spelled reset or rewrite depending 
on whether you want to read or write to the file.)


 The point is probably that a file isn't merely a feature free byte
 storage container; in the real world they usually come with all sorts of
 features like names and permissions. Those features will always imply
 creative uses.

There are at least three related but separate things here.

* file objects, or their low-level equivalent, file descriptors;

* pathnames;

* files on disk, which are an abstraction for data in a particular kind 
of data structure.

They are obviously related, but they are also obviously independent. You 
can have a pathname that doesn't refer to any file on disk; you can have 
a file on disk that has been lost, and therefore is no longer accessible 
via a file name. (If you run fsck or equivalent, the file may be 
recoverable, but the name will be lost.) You can open a file object, then 
unlink it so it no longer points to a file on disk, but does still accept 
read or write calls.

The counter-examples given so far apply to pathnames or files on disk. 
They don't apply to file objects and file descriptors. I have tried 
really hard to be clear that I am talking about file objects. To the 
extent that I have failed, I am sorry.


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


Re: object.enable() anti-pattern

2013-05-09 Thread Roy Smith
In article 518c7f05$0$29997$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 there is no way to create a C file descriptor in a closed state. Such 
 a thing does not exist. If you have a file descriptor, the file is 
 open. Once you close it, the file descriptor is no longer valid.

Of course there is.

int fd = 37;

I've just created a file descriptor.  There is not enough information 
given to know if it corresponds to an open file or not.

Before you protest that it's just an int, not a file descriptor, I 
should point out that they're the same thing.  It's pretty common to do 
something like:

for (int fd = 0; fd = MAX_FD; fd++) {
   close(fd)
}

before forking, to make sure all file descriptors are closed.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue17943] AttributeError: 'long' object has no attribute 'release' in Queue.put()

2013-05-09 Thread Georg Brandl

New submission from Georg Brandl:

I'm a bit puzzled by this exception in a long-running process
(running on Python 2.7.3):

...
  File /usr/lib/python2.7/Queue.py, line 138, in put
self.not_empty.notify()
item = ('message', 
'\x80\x02]q\x01(U\x05nicosq\x02GA\xd4b\xccu\xb0\xc0\xcaK\x15U\x01\nNU\x00e.')
self = Queue.Queue instance at 0x7f1d9c1c9e18
block= False
timeout  = None

  File /usr/lib/python2.7/threading.py, line 288, in notify
waiter.release()
waiter   = 7128680L
self = Condition(thread.lock object at 0x24a5590, 1)
_Condition__waiters  = [7128680L]
waiters  = [7128680L]
n= 1

AttributeError: 'long' object has no attribute 'release'


As far as I can see, there should only ever be lock objects in the 
self.__waiters list.  Does anyone see a possible reason for the long object to 
end up there?  (Sadly I can't debug the process anymore.)

--
messages: 188753
nosy: georg.brandl, pitrou
priority: normal
severity: normal
status: open
title: AttributeError: 'long' object has no attribute 'release' in Queue.put()
type: crash
versions: Python 2.7

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



[issue2704] IDLE: Patch to make PyShell behave more like a Terminal interface

2013-05-09 Thread Roger Serwy

Roger Serwy added the comment:

Welcome Phil! Your patch looks good and applied cleanly to the default branch 
and behaves as you specified. Your submission mechanics are good!

You might want to look into signing a contributor's agreement: 
http://docs.python.org/devguide/coredev.html#sign-a-contributor-agreement

--

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



[issue6699] IDLE: Warn user about overwriting a file that has a newer version on filesystem

2013-05-09 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


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

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



[issue17922] Crash in clear_weakref

2013-05-09 Thread Jan Safranek

Jan Safranek added the comment:

On 05/07/2013 06:06 PM, Antoine Pitrou wrote:
 a significant amount of static data inside CPython actually survives
 Py_Finalize :-/

As a solution, would it be possible to wipe all registered types in
Py_Finalize?

Jan

--

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



[issue17922] Crash in clear_weakref

2013-05-09 Thread Jan Safranek

Jan Safranek added the comment:

On 05/07/2013 05:32 PM, Antoine Pitrou wrote:
 Jan, one possibility would be for Pegasus to stop unloading Python,
 it seems.

It is always possibility. Actually, Pegasus plugin is just a shared
object (.so) and the .so is linked with Python. Pegasus calls dlopen()
and dlclose() on it. After dlclose(), the plugin is removed from
memory. Unfortunately, libpython2.7.so stays loaded, at least
/proc/XXX/mems says so. If there was a way to unload libpython2.7.so
from memory too...

Jan

--

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



[issue11354] argparse: nargs could accept range of options count

2013-05-09 Thread paul j3

paul j3 added the comment:

I think this patch should build on http://bugs.python.org/issue9849, which 
seeks to improve the error checking for nargs.  There, add_argument returns an 
ArgumentError if the nargs value is not a valid string, interger, or it there 
is mismatch between a tuple metavar and nargs.  

This range nargs should be tested at the same time, and return a ArgumentError 
if possible.

--

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



[issue16584] unhandled IOError filecmp.cmpfiles() if file not readable

2013-05-09 Thread Till Maas

Till Maas added the comment:

I just tried on a Windows 8 system with python from GIMP. The error occurs 
there as well if I compare two empty files after I removed permissions for one 
of the files. I do not know how to manage Windows' file ACLs in python, 
therefore I created the test case using the Explorer.

--

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



[issue17583] IDLE HOWTO

2013-05-09 Thread Amit Saha

Amit Saha added the comment:

Hello, I just wanted to check if I should attach the image files separately and 
submit the text as a diff? 

Thanks.

--

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



[issue17944] Refactor test_zipfile

2013-05-09 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Here is a patch which refactors test_zipfile, decreases it's size by 269 lines, 
makes adding tests for new compression types and new tests for all compression 
types simpler, and makes test_zipfile discoverable.

--
components: Tests
files: test_zipfile.patch
keywords: patch
messages: 188760
nosy: alanmcintyre, ezio.melotti, serhiy.storchaka, zach.ware
priority: normal
severity: normal
stage: patch review
status: open
title: Refactor test_zipfile
type: enhancement
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file30182/test_zipfile.patch

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



[issue17927] Argument copied into cell still referenced by frame

2013-05-09 Thread Nick Coghlan

Nick Coghlan added the comment:

Ah, I misread the second patch, I think due to the copy the cell into in
the comment. I believe I would have grasped it immediately if it said
something like reference the cell from.

--

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



[issue17941] namedtuple should support fully qualified name for more portable pickling

2013-05-09 Thread Richard Oudkerk

Richard Oudkerk added the comment:

 If the name is a qualified dotted name, it will be split and the first 
 part becomes the __module__.

That will not work correctly if the module name has a dot in it.

--
nosy: +sbt

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



[issue16601] Restarting iteration over tarfile continues from where it left off.

2013-05-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9b86fb6f5bc9 by Serhiy Storchaka in branch '2.7':
Issue #16601: Restarting iteration over tarfile no more continues from where
http://hg.python.org/cpython/rev/9b86fb6f5bc9

New changeset 9ed127d8ad61 by Serhiy Storchaka in branch '3.3':
Issue #16601: Restarting iteration over tarfile no more continues from where
http://hg.python.org/cpython/rev/9ed127d8ad61

New changeset 1c6a1427353b by Serhiy Storchaka in branch 'default':
Issue #16601: Restarting iteration over tarfile no more continues from where
http://hg.python.org/cpython/rev/1c6a1427353b

--
nosy: +python-dev

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



[issue16601] Restarting iteration over tarfile continues from where it left off.

2013-05-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for contribution.

I have committed simpler test.

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

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



[issue16601] Restarting iteration over tarfile continues from where it left off.

2013-05-09 Thread Michael Birtwell

Michael Birtwell added the comment:

Sorry about the delay in the contributor form. Things got in the way then I 
completely forgot about it. It's done now.

--

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



[issue16631] tarfile.extractall() doesn't extract everything if .next() was used

2013-05-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Patch for issue16601 has fixed this issue too.

--
resolution:  - duplicate
stage: patch review - committed/rejected
status: open - closed
superseder:  - Restarting iteration over tarfile continues from where it left 
off.

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



[issue17656] Python 2.7.4 breaks ZipFile extraction of zip files with unicode member paths

2013-05-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Shouldn't it left opened until regression fix release has released.

--

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



[issue17656] Python 2.7.4 breaks ZipFile extraction of zip files with unicode member paths

2013-05-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't think so. The bug is fixed, and the fix will be in the release.

--

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



[issue17809] FAIL: test_expanduser when $HOME ends with /

2013-05-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset dee0a2dea11e by Ezio Melotti in branch '3.3':
#17809: fix a test failure in test_expanduser when $HOME has a trailing /.  
Patch by Kubilay Kocak.
http://hg.python.org/cpython/rev/dee0a2dea11e

New changeset 489f075430de by Ezio Melotti in branch 'default':
#17809: merge with 3.3.
http://hg.python.org/cpython/rev/489f075430de

--
nosy: +python-dev

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



[issue17943] AttributeError: 'long' object has no attribute 'release' in Queue.put()

2013-05-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Waiters are created through _allocate_lock(), so you should look there.

But, unless you have further info, I don't think keeping this open as a bug is 
useful.

--

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



[issue17809] FAIL: test_expanduser when $HOME ends with /

2013-05-09 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the patch!

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

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



  1   2   >