Re: An object is an instance (or not)?

2015-01-28 Thread Steven D'Aprano
Gregory Ewing wrote:

 Mario Figueiredo wrote:
 I couldn't think of a way to
 demonstrate that a class object does not participate in its own
 inheritance rules. Only instances of it can.
 
 I think I may see where your reasoning is going astray.
 You think that an instance inherits methods from its
 class in the same way that a subclass inherits methods
 from its base class.

In fairness, inherit is standard terminology for the way instances get
their behaviour from their class.

Also, you can override methods *on the instance*:


py class Parrot(object):
... def talk(self):
... print(Polly wants a cracker!)
...
py polly = Parrot()
py polly.talk()
Polly wants a cracker!
py from types import MethodType
py polly.talk = MethodType(
... lambda self: print(Polly wants a spam sandwich!), polly)
py polly.talk()
Polly wants a spam sandwich!



 But thinking of the instance-class relationship as
 an inheritance relationship is misleading. It's more
 accurate to say that a class *defines* the methods
 that its instances have. The class inherits methods
 from its base class, but those methods still apply to
 instances of the class, not the class itself.

I won't speak for other OOP models, but I don't think that is true in
Python. In Python, obj.talk performs the following (grossly simplified)
process:

* search the instance for an attribute talk
* search the class
* search all the base classes
* fail

(simplified because I have ignored the roles of __getattr__ and
__getattribute__, of metaclasses, and the descriptor protocol)


That's more or less the same as what happens whether obj is a class object
or a non-class object. I don't know what attribute lookup *literally* uses
the exact same code for looking up attributes on an instance or a class,
but it wouldn't surprise me if it does.


 That doesn't mean the class itself can't be given
 methods, though. The methods of the class are defined
 by its metaclass, and the metaclass inherits methods
 from *its* base class, etc.


The normal way of giving a class methods that are callable from the class is
to define them on the class with the classmethod or staticmethod
decorators. Using a metaclass is usually overkill :-)



 Here's a diagram:
 
 +--+  ++
 | type |  | base class |
 +--+  ++
 ^   ^
 | subclass of   | subclass of
 |   |
 +---+  +---+  +--+
 | metaclass |-| class |-| instance |
 +---+  instance of +---+  instance of +--+
 
 It should be clear from this that the relationship
 between an instance and its class is exactly the same
 as that between a class and its metaclass, including
 inheritance relationships.
 
 The diagram can be extended indefinitely far to the
 left -- the metaclass could be an instance of a
 meta-metaclass, etc. (Although there's an old standing
 joke in the Python world that metaclasses make your
 head explode, so I hate to think what a meta-metaclass
 would do -- probably take out a whole floor of the
 office building you work in. Meta-meta-metaclasses are
 right out.)

An early essay on Python metaclasses was subtitled The Killer-Joke. 




-- 
Steven

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


Re: write file to a server

2015-01-28 Thread MRAB

On 2015-01-28 13:22, luca72 wrote:

Hello i'm under windows, i have to write a file from my computer to a
local server like taht \\DOCUMENTALE\my_folder\.
How i have to proceed ?

That's a path to a folder that just happens to be on another computer on 
your network. Treat it the same way you would for a 'local' folder,

eg C:\my_folder.

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


Re: write file to a server

2015-01-28 Thread Chris Angelico
On Thu, Jan 29, 2015 at 12:38 AM, MRAB pyt...@mrabarnett.plus.com wrote:
 On 2015-01-28 13:22, luca72 wrote:

 Hello i'm under windows, i have to write a file from my computer to a
 local server like taht \\DOCUMENTALE\my_folder\.
 How i have to proceed ?

 That's a path to a folder that just happens to be on another computer on
 your network. Treat it the same way you would for a 'local' folder,
 eg C:\my_folder.

And if you've done that and it isn't working, one likely cause is that
Windows uses backslashes in path names, but Python string literals
treat backslashes specially. Use a raw string literal:

path = r\\DOCUMENTALE\my_folder\some_file_name
with open(path, wb) as f:
... write to file ...

If you have other problems, the best thing to do is to post your code
and the exact output it produces, especially if that's a traceback.
Those are incredibly helpful.

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


Re: parsing tree from excel sheet

2015-01-28 Thread Tim Chase
On 2015-01-28 10:12, alb wrote:
 I've a document structure which is extremely simple and represented
 on a spreadsheet in the following way (a made up example):
 
 subsystem | chapter | section | subsection | subsubsec |
 A | | ||   |
   | func0   | ||   |
   | |interface||   |
   | |latency  ||   |
   | |priority ||   |
   | func1   | ||   |
   | |interface||   |
   | |latency  ||   |
   | |priority ||   |
 
 And I'd like to get a tree like this:
 
 A
 +--- func0
 |   +--- interface
 |   +--- latency
 |   \--- priority
 \--- func1
 +--- interface
 +--- latency
 +--- priority
 
 I know about the xlrd module to get data from excel

If I have to get my code to read Excel files, xlrd is usually my
first and only stop.

 Does anyone recommend any other path other than scripting through
 these two modules?

Well, if you export from Excel as CSV, you can use the csv module
in the standard library.  This is actually my preferred route because
it prevents people (coughclientscough) from messing up the CSV file
with formatting, joined cells, and other weirdnesses that can choke
my utilities.

 Is there any more suitable module/example/project out there that
 would achieve the same result?

I don't believe there's anything that will natively do the work for
you.  Additionally, you'd have to clarify what should happen if two
rows in the same section had different sub-trees but the same
content/name.  Based on your use-case (LaTex export using these as
headers) I suspect you'd want a warning so you can repair the input
and re-run.  But it would be possible to default to either keeping or
squashing the duplicates.

 p.s.: I'm not extremely proficient in python, actually I'm just
 starting with it!

Well, you've come to the right place. Most of us are pretty fond of
Python here. :-)

-tkc




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


[issue23193] Please support numeric_owner in tarfile

2015-01-28 Thread Eric V. Smith

Changes by Eric V. Smith e...@trueblade.com:


--
stage: test needed - patch review

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



[issue23335] _ssl.c cannot be compiled with older versions of OpenSSL

2015-01-28 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



python on mobile mailing list

2015-01-28 Thread Fetchinson .
Hi all, the mobile-sig mailing list is alive:

https://mail.python.org/pipermail/mobile-sig/2015-January/thread.html

If you are interested in python on smart phones that's the place to go!

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
https://mail.python.org/mailman/listinfo/python-list


OSCON 2015 CfP DEADLINE Feb 2

2015-01-28 Thread Aahz
OSCON (O'Reilly Open Source Conference) will be held in Portland, OR July
20-24.  The Call for Proposals is now open with a DEADLINE of Monday
February 2:

http://www.oscon.com/open-source-2015/public/cfp/360

O'Reilly has completely reorganized OSCON.  Instead of focusing on
individual technologies, there are a bunch of themes:

 * Identity - An emerging and nuanced facet in the digital age and an
   exciting cross-functional track at OSCON 2015.

 * Security - We'll explore security from top to bottom, offering
   frameworks and libraries, strategies for testing, and field reports
   of both security failure and success.

 * Privacy - Computers remember our interactions at a level of detail
   the physical world never has. Do we want to be remembered, and for
   how long?

 * Performance - From compilation and interpreter time to DOM
   manipulation, browser responsiveness, and network latency, we'll
   explore performance in all its facets.

 * Mobility - We'll look at what it means to have a successful mobile
   game plan, from wearables to native apps.

 * People - Making projects work requires communications,
   collaboration, and respect; we'll look at the ways a new generation
   of tools and approaches can help you work.

 * Architecture - Software architecture is a massive multidisciplinary
   subject, covering many roles and responsibilities--and a key
   position in the success of any business.

 * Scale - You've created a great web interface that is well designed,
   secure, and works well in a beta with 100 consumers, but how about
   10,000, 1,000,000, or more?

 * Storage - Find your way among the myriad choices for storing data
   and optimizing your systems for stability, distribution,
   convenience, and performance.

 * Teaching - You want to share your best practices, projects, and
   tools with the world, but how do you go about sharing this
   knowledge? We'll examine learning theory and methods of teaching.

 * Design - It's critical for success; learn how to incorporate design
   best practices from the beginning of your project rather and all
   the way through.

 * Solve - Harness the power of math to manipulate, secure, and create
   data.

 * Data - Let's tackle data's continued, growing influence over the
   entire business world and how you can make it work for you.

 * Foundations - A strong foundation in computational thinking,
   problem solving, and programming best practices makes for a
   successful programmer.

See the CfP page for more details.
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code --
not in reams of trivial code that bores the reader to death.  --GvR
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Re: An object is an instance (or not)?

2015-01-28 Thread Steven D'Aprano
Ben Finney wrote:

 Ned Batchelder n...@nedbatchelder.com writes:
 
 On 1/27/15 3:12 PM, Mario Figueiredo wrote:
  This is a follow up from a previous discussion in which it is argued
  that the following code produces the correct error message terminology,
  considering that in Python an object is also an instance.

 I don't know what the difference is between object and instance.
 An object is an instance of a class.  The two words are
 interchangeable as far as I know.
 
 Not in English grammar, IMO. To say “foo is an instance” implies the
 sentence isn't finished; the term “instance” only makes sense in the
 context of a relationship to some class. To say “foo is an object”
 doesn't have that implication.

I'm sure that there is a grammatical term for this, but I don't know it. 
Regardless of the terminology though, foo is an instance is a complete 
sentence fragment:

foo is an instance (of some unspecified class)

is the same grammatical construct as:

George is a soldier (of some unspecified army)
Pluto is a cartoon animal (of some unspecified species)
Bearhugger's Old Peculiar is a drink (of some unspecified type)
Herbie is a car (of some unspecified make and model)

etc. In Java, the term object as a synonym for instance is unambiguous, 
because in Java all classes are subclasses of Object, and no classes are 
themselves instances of a class. But that's not the case with Python.


 A common mistake is to believe that OOP is a well-defined term.
 It's not it's a collection of ideas that are expressed slightly
 differently in each language.
 
 Right. The common meaning of “object” shared by all OOP systems is
 surprisingly small.

Agreed. There really is no widespread agreement on what OOP means 
*precisely*. Wikipedia states:

Attempts to find a consensus definition or theory behind objects have not 
proven very successful and there is little agreement of the fundamental 
features of OOP:

http://en.wikipedia.org/wiki/Object-
oriented_programming#Fundamental_features_and_concepts


[...] 
 In Python, every class is an object. Every class has the full range of
 behaviour that we expect of objects. A class just has the additional
 feature that it can be instantiated.

We can also define an is-a relationship between classes and their 
instances:

[1, 2, spam] is-a list;

but not list is-a [1, 2, spam]


However, in Python that breaks down at the very bottom of the inheritance 
hierarchy, thanks to the circular relationship between type and object:

py isinstance(type, object)
True
py isinstance(object, type)
True

type is-a object
object is-a type



-- 
Steve

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


[issue22079] Ensure in PyType_Ready() that base class of static type is static

2015-01-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c087ac6fc171 by Serhiy Storchaka in branch '2.7':
Issue #22079: PyType_Ready() now checks that statically allocated type has
https://hg.python.org/cpython/rev/c087ac6fc171

New changeset 747855f29b9d by Serhiy Storchaka in branch '3.4':
Issue #22079: PyType_Ready() now checks that statically allocated type has
https://hg.python.org/cpython/rev/747855f29b9d

New changeset eb26255e11f1 by Serhiy Storchaka in branch 'default':
Issue #22079: PyType_Ready() now checks that statically allocated type has
https://hg.python.org/cpython/rev/eb26255e11f1

--
nosy: +python-dev

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



Re: parsing tree from excel sheet

2015-01-28 Thread Peter Otten
alb wrote:

 Hi everyone,
 
 I've a document structure which is extremely simple and represented on a
 spreadsheet in the following way (a made up example):
 
 subsystem | chapter | section | subsection | subsubsec |
 A | | ||   |
   | func0   | ||   |
   | |interface||   |
   | |latency  ||   |
   | |priority ||   |
   | func1   | ||   |
   | |interface||   |
   | |latency  ||   |
   | |priority ||   |
   | |depend   ||   |
   | | | variables  |   |
   | | || static|
   | | || global|
   | | | functions  |   |
   | | || internal  |
   | | || external  |
 
 And I'd like to get a tree like this:
 
 A
 +--- func0
 |   +--- interface
 |   +--- latency
 |   \--- priority
 \--- func1
 +--- interface
 +--- latency
 +--- priority
 \--- depend
  +--- variables
  | +--- static
  | \--- local
  \--- functions
+--- internal
\--- external
 
 I know about the xlrd module to get data from excel and I'm also aware
 about the ETE toolkit (which is more specific for bioinformatics, but I
 guess can suitable fill the need).
 
 Does anyone recommend any other path other than scripting through these
 two modules?
 
 Is there any more suitable module/example/project out there that would
 achieve the same result?
 
 The reason for parsing is because the need behind is to create documents
 edited in excel but typeset in LaTeX, therefore my script will spill out
 \chapter, \section and so forth based on the tree structure.
 
 Every node will have some text and some images with a very light markup
 like mediawiki that I can easily convert into latex.
 
 Hope I've not been too confusing.
 Thanks for any pointer/suggestion/comment.
 
 Al
 
 p.s.: I'm not extremely proficient in python, actually I'm just starting
 with it!

You can save the excel sheet as csv so that you an use the csv module which 
may be easier to use than xlrd. The rest should be doable by hand. Here's 
what I hacked together:

$ cat parse_column_tree.py
import csv

def column_index(row):
for result, cell in enumerate(row, 0):
if cell:
return result
raise ValueError


class Node:
def __init__(self, name, level):
self.name = name
self.level = level
self.children = []

def append(self, child):
self.children.append(child)

def __str__(self):
return \%s{%s} % (self.level, self.name)

def show(self):
yield [self.name]
for i, child in enumerate(self.children):
lastchild = i == len(self.children)-1
first = True
for c in child.show():
if first:
yield [\---  if lastchild else +--- ] + c
first = False
else:
yield [   if lastchild else | ] + c
def show2(self):
yield str(self)
for child in self.children:
yield from child.show2()

def show(root):
for row in root.show():
print(.join(row))

def show2(root):
for line in root.show2():
print(line)

def read_tree(rows, levelnames):
root = Node(#ROOT, #ROOT)
old_level = 0
stack = [root]
for i, row in enumerate(rows, 1):

new_level = column_index(row)
node = Node(row[new_level], levelnames[new_level])

if new_level == old_level:
stack[-1].append(node)
elif new_level  old_level:
if new_level - old_level != 1:
raise ValueError

stack.append(stack[-1].children[-1])
stack[-1].append(node)
old_level = new_level
else:
while new_level  old_level:
stack.pop(-1)
old_level -= 1
stack[-1].append(node)
return root

def main():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(infile)
parser.add_argument(--latex, action=store_true)

args = parser.parse_args()

with open(args.infile) as f:
rows = csv.reader(f)
levelnames = next(rows) # skip header
tree = read_tree(rows, levelnames)

show_tree = show2 if args.latex else show
   

Re: Python is DOOMED! Again!

2015-01-28 Thread Skip Montanaro
On Tue, Jan 27, 2015 at 7:26 PM, Steven D'Aprano 
steve+comp.lang.pyt...@pearwood.info wrote:

 (2) Algol, Ada, Boo, C, C#, C++, Cobol, Cobra, D, F#, Fantom, Fortran, Go,
 Haskell, Java, Julia, Kotlin, Oberon, Pascal, Rust, Scala and dozens
 (hundreds?) of other languages disagree with you.


Well, sure. But that's always been one of the nice things about Python,
less visual clutter. While I understand where all the type hinting activity
is coming from (and accept it as inevitable), I'm also sympathetic to
Mario's perspective.

Python-1.5-anyone?-ly, y'rs,

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: parsing tree from excel sheet

2015-01-28 Thread alb
Hi Peter,

Peter Otten __pete...@web.de wrote:
[]
 You can save the excel sheet as csv so that you an use the csv module which 
 may be easier to use than xlrd. The rest should be doable by hand. Here's 
 what I hacked together:
 
 $ cat parse_column_tree.py
 import csv
 
 def column_index(row):
for result, cell in enumerate(row, 0):
if cell:
return result
raise ValueError
 
 
 class Node:
def __init__(self, name, level):
self.name = name
self.level = level
self.children = []
 
def append(self, child):
self.children.append(child)
 
def __str__(self):
return \%s{%s} % (self.level, self.name)
 
def show(self):
yield [self.name]
for i, child in enumerate(self.children):
lastchild = i == len(self.children)-1
first = True
for c in child.show():
if first:
yield [\---  if lastchild else +--- ] + c
first = False
else:
yield [   if lastchild else | ] + c
def show2(self):
yield str(self)
for child in self.children:
yield from child.show2()
 
 def show(root):
for row in root.show():
print(.join(row))
 
 def show2(root):
for line in root.show2():
print(line)
 
 def read_tree(rows, levelnames):
root = Node(#ROOT, #ROOT)
old_level = 0
stack = [root]
for i, row in enumerate(rows, 1):
 
new_level = column_index(row)
node = Node(row[new_level], levelnames[new_level])
 
if new_level == old_level:
stack[-1].append(node)
elif new_level  old_level:
if new_level - old_level != 1:
raise ValueError
 
stack.append(stack[-1].children[-1])
stack[-1].append(node)
old_level = new_level
else:
while new_level  old_level:
stack.pop(-1)
old_level -= 1
stack[-1].append(node)
return root
 
 def main():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(infile)
parser.add_argument(--latex, action=store_true)
 
args = parser.parse_args()
 
with open(args.infile) as f:
rows = csv.reader(f)
levelnames = next(rows) # skip header
tree = read_tree(rows, levelnames)
 
show_tree = show2 if args.latex else show
for node in tree.children:
show_tree(node)
print()
 
 if __name__ == __main__:
main()
 $ cat data.csv
 subsystem,chapter,section,subsection,subsubsec,
 A,
 ,func0
 ,,interface,,,
 ,,latency,,,
 ,,priority,,,
 ,func1
 ,,interface,,,
 ,,latency,,,
 ,,priority,,,
 ,,depend,,,
 ,,,variables,,
 static,
 global,
 ,,,functions,,
 internal,
 external,
 $ python3 parse_column_tree.py data.csv
 A
 +--- func0
 | +--- interface
 | +--- latency
 | \--- priority
 \--- func1
  +--- interface
  +--- latency
  +--- priority
  \--- depend
+--- variables
| +--- static
| \--- global
\--- functions
  +--- internal
  \--- external
 
 $ python3 parse_column_tree.py data.csv --latex
 \subsystem{A}
 \chapter{func0}
 \section{interface}
 \section{latency}
 \section{priority}
 \chapter{func1}
 \section{interface}
 \section{latency}
 \section{priority}
 \section{depend}
 \subsection{variables}
 \subsubsec{static}
 \subsubsec{global}
 \subsection{functions}
 \subsubsec{internal}
 \subsubsec{external}

WOW! I didn't really want someone else to write what I needed but thanks 
a lot! That's a lot of food to digest in a single byte, so I'll first 
play a bit with it (hopefully understanding what is doing) and then come 
back with comments.

I really appreciated your time and effort.

Al
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23332] datetime.isoformat() - explicitly mark UTC string as such

2015-01-28 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

 ISO 8601 can and should be understood such as the TZ-designator is required 
 (I think we agreed on that).

No.  There is no such requirement in ISO 8601 as far as I remember.

--

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



[issue22799] wrong time.timezone

2015-01-28 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Isn't this a duplicate of #13466?

--

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



[issue22798] time.mktime doesn't update time.tzname

2015-01-28 Thread Alexander Belopolsky

Changes by Alexander Belopolsky alexander.belopol...@gmail.com:


--
nosy: +belopolsky

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



Re: Beginner question - class definition error

2015-01-28 Thread Cousin Stanley

 from kivy.app import App
 from kivy.uix.label import Label
 
 class MyApp(App):
   def build(self):
 return Label(text='Hello World')
 
   if __name__ == '__main__':
 MyApp().run()

 

 I get this error when I run it:
 

 Traceback (most recent call last):
   File MinimalApplication.py, line 7, in module
 class MyApp(App):
   File MinimalApplication.py, line 12, in MyApp
 MyApp().run()
 NameError: name 'MyApp' is not defined

 How can I fix this please?
 
  Try removing beginning indentation 
  from 

if __name__ == '__main__': 
  
if __name__ == '__main__':


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


write file to a server

2015-01-28 Thread luca72
Hello i'm under windows, i have to write a file from my computer to a local 
server like taht \\DOCUMENTALE\my_folder\.
How i have to proceed ?

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


[issue23332] datetime.isoformat() - explicitly mark UTC string as such

2015-01-28 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Why do you call it a bug?  Specifying UTC as +00:00 is perfectly valid by ISO 
8601 and some RFCs that are based on the ISO standard recommend against using 
the Z code.

--

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



[issue22799] wrong time.timezone

2015-01-28 Thread Alexander Belopolsky

Changes by Alexander Belopolsky alexander.belopol...@gmail.com:


--
nosy: +belopolsky

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



[issue22609] Constructors of some mapping classes don't accept `self` keyword argument

2015-01-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

So may be close this issue?

See also issue22958.

--

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



Re: An object is an instance (or not)?

2015-01-28 Thread Steven D'Aprano
random...@fastmail.us wrote:

 I think his objection is to the use of the phrase 'Sub' object to
 refer only to instances of the Sub type, when 'Sub' is the name of the
 type object itself and therefore (he thinks) 'Sub' object should refer
 to it instead. (I can only assume he wants 'x' object for x = Sub().)


Yes, that's exactly what Mario asked for in the original thread that started 
this. Sadly Python cannot do this.

But the docs could consistently use class or type to refer to classes 
and types (in Python 3, they are the same thing), and instance to refer to 
instances which are not classes, and object to refer to both.

And then I would be sooo happyy :-)


-- 
Steve

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


[issue23285] PEP 475 - EINTR handling

2015-01-28 Thread Charles-François Natali

Charles-François Natali added the comment:

 I added a few prints to the send and receive loops of _test_send.  When 
 running on a reasonably current Debian testing Linux:

Thanks, that's what I was suspecting, but I really don't understand
why 200ms isn't enough for a socket write to actually do something:
maybe OS-X and *BSD schedulers are large timeslice...

Could you try by increasing signal_period to e.g. 0.5, and sleep_time to 1?

--

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



[issue18898] Apply the setobject optimizations to dictionaries

2015-01-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

noincref.diff doesn't contain all necessary changes. For example dummy is 
increfed in dict_pop() and dict_popitem() and may be decrefed at insert.

As in sets we can got rid of few comparisons with dummy if set dummy hashes to 
-1.

--

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



Re: An object is an instance (or not)?

2015-01-28 Thread Steven D'Aprano
Ben Finney wrote:

 * In the distant past of Python, some objects were not instances of any
 class; the terminology in the documentation and messages shows some
 confusing legacies from that ancient time.


I presume you are referring to the type/class distinction?

That is, in Python 1.5 (for example), the *instance* 23 was an instance of 
the *type* int but not of any class, as classes (created with the class 
keyword) were distinct from types.

If you mean something else, can you explain please?


-- 
Steve

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


[issue23337] Run python with restricted rights

2015-01-28 Thread Marc

New submission from Marc:

Hi,

We work in a school within a domain and pupils are using different restricted 
account on this domain. We tried to install Python 3.4 and it's work with an 
Administrator Account.


With Children account , we got the message IDLE's subprocess didn't make 
connection. Either IDLE can't start a subprocess or personal firewall software 
is blocking the connection  .


We checked if there is any python file in the  python.exe directory like 
advised on 
http://stackoverflow.com/questions/874757/python-idle-subprocess-error.

We also tried to give more right on the python directory for the children 
account.

If anyone have a solution please let me know.

Thanks

--
components: Windows
files: python_error.png
messages: 234883
nosy: marcd, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Run python with restricted rights
type: crash
versions: Python 3.4
Added file: http://bugs.python.org/file37889/python_error.png

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



[issue22687] horrible performance of textwrap.wrap() with a long word

2015-01-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ping. What can I do to move this issue forward?

--

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



Re: Is there a more elegant way to spell this?

2015-01-28 Thread Mario Figueiredo
In article mailman.18197.1422408555.18130.python-l...@python.org, 
ben+pyt...@benfinney.id.au says...
 
 More accurately (and as acknowledged in that guide), a single underscore
 *is* a common name for a ?don't care? name, but is better avoided for
 that purpose because it's also commonly used for other purposes.
 
 In other words: That guide is correct in its admonition, but that
 doesn't challenge what Steven said about common usage.

I was not trying to challenge his assertion. Only adding more 
information to it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: An object is an instance (or not)?

2015-01-28 Thread Steven D'Aprano
Ned Batchelder wrote:

 Do you have a reference that defines these terms?

*A* reference is not sufficient. It has to be a reference which all other 
references agree with.

I'll be kind, and lower the requirement to one where *the majority* of other 
references agree. The OP still won't find one :-)

Or perhaps that should be a sad face smiley :-( How much time we would all 
save if academics and language designers would only stick to a single 
consistent terminology across all languages.


-- 
Steven

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


[issue5700] io.FileIO calls flush() after file closed

2015-01-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ping.

--

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



parsing tree from excel sheet

2015-01-28 Thread alb
Hi everyone,

I've a document structure which is extremely simple and represented on a 
spreadsheet in the following way (a made up example):

subsystem | chapter | section | subsection | subsubsec |
A | | ||   |
  | func0   | ||   |
  | |interface||   |
  | |latency  ||   |
  | |priority ||   |
  | func1   | ||   |
  | |interface||   |
  | |latency  ||   |
  | |priority ||   |
  | |depend   ||   |
  | | | variables  |   |
  | | || static|
  | | || global|
  | | | functions  |   |
  | | || internal  |
  | | || external  |

And I'd like to get a tree like this:

A
+--- func0
|   +--- interface
|   +--- latency
|   \--- priority
\--- func1
+--- interface
+--- latency
+--- priority
\--- depend
 +--- variables
 | +--- static
 | \--- local
 \--- functions
   +--- internal
   \--- external

I know about the xlrd module to get data from excel and I'm also aware 
about the ETE toolkit (which is more specific for bioinformatics, but I 
guess can suitable fill the need).

Does anyone recommend any other path other than scripting through these 
two modules?

Is there any more suitable module/example/project out there that would 
achieve the same result?

The reason for parsing is because the need behind is to create documents 
edited in excel but typeset in LaTeX, therefore my script will spill out 
\chapter, \section and so forth based on the tree structure.

Every node will have some text and some images with a very light markup 
like mediawiki that I can easily convert into latex.

Hope I've not been too confusing.
Thanks for any pointer/suggestion/comment.

Al

p.s.: I'm not extremely proficient in python, actually I'm just starting 
with it!

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: An object is an instance (or not)?

2015-01-28 Thread Steven D'Aprano
random...@fastmail.us wrote:

 On Tue, Jan 27, 2015, at 16:06, Mario Figueiredo wrote:
 That error message has me start that thread arguing that the error is
 misleading because the Sub object does have the __bases__ attribute.
 It's the Sub instance object that does not have it.
 
 What do you think Sub object means?

I think it means the Sub class, which is an object. And Python 3.3 agrees 
with me:

py class Sub(object):
... pass
... 
py isinstance(Sub, object)
True

Sub is also an instance of type. And object is an instance of type, type is 
an instance of object, and type is a subclass of object. But object is not a 
subclass of type. However it is an instance of type. Are we confused yet?

There is a sense, taken from Java in particular, that object is synonymous 
for instance. For example, Oracle's documentation for classes says:

A class contains constructors that are invoked to create objects from the 
class blueprint.

http://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html

But you won't find any Java documentation referring to the class itself as 
an object. Java has no metaclasses, classes are not instances of a 
metaclass, and so classes are never instances. Classes are classes, objects 
are instances of a class, and that is all there is to it.

But in Python, object and instance are more ambiguous, thanks to 
metaclasses. Instances of a metaclass are classes, hence classes are 
instances as well as classes:

py isinstance(Sub, type)
True

Sub is an instance of the class type. And because classes themselves are 
first-class (ha ha!) values, like ints, strings, lists etc., classes are 
objects.

All classes (in Python 3) are instances of a class (the metaclass), but not 
all instances are classes.

Obviously this is rather confusing, but fortunately metaclasses (other than 
type itself) are rare, so *most of the time* we can get away with Java-like 
terminology, and pretend that classes are distinct from instances rather 
than being just another kind of instance (of the metaclass).

But what we cannot do is pretend that object means instance, because all 
classes are objects. Alas, habits from other languages leak in, and the 
Javaesque terminology Foo object meaning an instance of Foo sometimes gets 
used, even though Foo object should refer to the object called Foo, namely 
the class object itself.

The unfortunate ambiguity is that sometimes Foo object gets used to mean 
Foo, and other times it gets used to me some instance of Foo. We say:

the None object has no state

and

the function requires an int object as argument.



 Sub itself is not a Sub object,

Sub itself is not *a* Sub object, it is *the* Sub object, just as 42 is 
*the* object with type int and value forty-two.


 it is a type object. instance is
 implicit in the phrase foo object.

Alas, classes *are* instances, of their metaclass, so Sub object could 
refer to an instance of Sub (using the Javaesque terminology) or Sub itself 
(using more Pythonistic terminology).



-- 
Steven

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


Re: An object is an instance (or not)?

2015-01-28 Thread Steven D'Aprano
random...@fastmail.us wrote:

 On Wed, Jan 28, 2015, at 00:43, Devin Jeanpierre wrote:
 On Tue, Jan 27, 2015 at 9:37 PM,  random...@fastmail.us wrote:
  Sub itself is not a Sub object, it is a type object. instance is
  implicit in the phrase foo object.
 
 Yes. Unfortunately, it's still not really completely clear. Sub
 instance would avoid this confusion for everyone.
 
 It really is completely clear. Nobody is confused but you.

Ironically, your denial of a pretty clear case of ambiguity demonstrates 
that if anyone is confused, it is you.

In an earlier thread, Mario demonstrated an obvious example of confusing 
error message due to the object/instance ambiguity, where the error message 
states that Sub doesn't have a method when it actually does. It is an 
*instance of Sub*, not the Sub object itself, which lacks the method.


-- 
Steve

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


Re: An object is an instance (or not)?

2015-01-28 Thread Steven D'Aprano
Mario Figueiredo wrote:

 In other words, the object know as Sub class is not an instance
 object. True, it is an instance of the object 'type'.


Can you not see the contradiction there?

The object known as 42 is not an instance object. True, it is an instance of 
the object int.

Er, then surely that means that 42 *is* an instance object?

I agree that in *common situations*, it is useful to pretend that Python is 
like Java, and draw a distinction between classes and instances. I don't 
think it is useful to deny that classes are instances.

The discussion depends on context, in the same way that depending on context 
sometimes it is useful to include Homo sapiens in the group Animals and 
sometimes not:

Sit up straight and stop eating like an animal!

Like all animals, human beings rely on the environment for their survival.


-- 
Steve

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


[issue14260] re.groupindex is available for modification and continues to work, having incorrect data inside it

2015-01-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ping.

--
keywords: +needs review

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



[issue22721] pprint output for sets and dicts is not stable

2015-01-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ping.

--

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



Re: An object is an instance (or not)?

2015-01-28 Thread Steven D'Aprano
Mario Figueiredo wrote:

 In article mailman.18191.1422400930.18130.python-l...@python.org,
 n...@nedbatchelder.com says...
 
 A common mistake is to believe that OOP is a well-defined term.  It's
 not it's a collection of ideas that are expressed slightly differently
 in each language.
 
 A common mistake is thinking just because OOP has different
 implementations, it doesn't have a cohesive set of well described rules
 and its own well defined terminology.

Alas, this is not a mistake. As I posted in a reply to Ben, OOP does not 
have a cohesive set of rules and well-defined terminology.


 I don't know what a not fully realized object is.
 
 A fully realized object, in an object oriented paradigm, is an object
 containing or pointing to data and the methods to act on that data. It's
 an instance of a class.

In Python, classes meet that definition too. A class in Python is a value 
which can contain data (or point to data), and it has methods which act on 
that data. Classes in Python themselves have a class, which we call the 
metaclass, and classes inherit behaviour from their class just as integer 
instances inherit behaviour from their class, int.


 A *not* fully realized object is possible in Python, since Classes are
 first-class objects, despite not being able to participate in OOP.
 
 
 What does participate in OOP mean?
 
 Means the object is capable of participating in inheritance and/or
 polymorphism. An instance of an object is capable of doing so, per its
 class definitions. Whereas a Python class object is not.

Class objects are capable of participating in inheritance. A class can have 
multiple metaclasses. They can even have multiple inheritance of 
metaclasses.

I'm not sure what relevance polymorphism has.



-- 
Steven

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


Re: An object is an instance (or not)?

2015-01-28 Thread Chris Angelico
On Wed, Jan 28, 2015 at 8:16 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Or perhaps that should be a sad face smiley :-( How much time we would all
 save if academics and language designers would only stick to a single
 consistent terminology across all languages.

That's like wishing that every human spoke the same language, instead
of having English, French, Italian, Polish, Serbian, Korean, and a
host of others. The problem isn't the languages; the variety of
languages reflects a variety of concepts being communicated, and to
unify the languages spoken would entail dispensing with that variety.

The terminology isn't consistent because there are myriad variations
between the concepts. Is it useful to talk about multiple
inheritance as a concept? I believe I've yet to meet two distinct
languages that have identical MI semantics. Does each language need
its own word for that term so we don't have any sort of
inconsistencies? Or do all languages have to implement the exact same
functionality?

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


Re: An object is an instance (or not)?

2015-01-28 Thread Gregory Ewing

Mario Figueiredo wrote:
I couldn't think of a way to 
demonstrate that a class object does not participate in its own 
inheritance rules. Only instances of it can.


I think I may see where your reasoning is going astray.
You think that an instance inherits methods from its
class in the same way that a subclass inherits methods
from its base class.

But thinking of the instance-class relationship as
an inheritance relationship is misleading. It's more
accurate to say that a class *defines* the methods
that its instances have. The class inherits methods
from its base class, but those methods still apply to
instances of the class, not the class itself.

That doesn't mean the class itself can't be given
methods, though. The methods of the class are defined
by its metaclass, and the metaclass inherits methods
from *its* base class, etc.

Here's a diagram:

+--+  ++
| type |  | base class |
+--+  ++
   ^   ^
   | subclass of   | subclass of
   |   |
+---+  +---+  +--+
| metaclass |-| class |-| instance |
+---+  instance of +---+  instance of +--+

It should be clear from this that the relationship
between an instance and its class is exactly the same
as that between a class and its metaclass, including
inheritance relationships.

The diagram can be extended indefinitely far to the
left -- the metaclass could be an instance of a
meta-metaclass, etc. (Although there's an old standing
joke in the Python world that metaclasses make your
head explode, so I hate to think what a meta-metaclass
would do -- probably take out a whole floor of the
office building you work in. Meta-meta-metaclasses are
right out.)

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


[issue23338] PyErr_Format in ctypes uses invalid parameter

2015-01-28 Thread Makoto Kato

New submission from Makoto Kato:

This is CYGWIN build only.

When ctypes cannot find function in CDataType_in_dll, it uses PyErr_Format.  
But it passes invalid parameters.

--
components: ctypes
messages: 234886
nosy: mkato
priority: normal
severity: normal
status: open
title: PyErr_Format in ctypes uses invalid parameter
type: crash
versions: Python 2.7

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



Re: An object is an instance (or not)?

2015-01-28 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes:

 Ben Finney wrote:

  * In the distant past of Python, some objects were not instances of any
  class; the terminology in the documentation and messages shows some
  confusing legacies from that ancient time.


 I presume you are referring to the type/class distinction?

 That is, in Python 1.5 (for example), the *instance* 23 was an
 instance of the *type* int but not of any class, as classes (created
 with the class keyword) were distinct from types.

That's what I was referring to, yes.

All ancient history now. In all current versions of Python, every type
is a class and every class is a type, and every type is an object and
every class is an object, and every object is an instance of a class and
is an instance of a type (and you are me and all are we together).

-- 
 \  “I like to reminisce with people I don't know. Granted, it |
  `\ takes longer.” —Steven Wright |
_o__)  |
Ben Finney

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


Re: Beginner question - class definition error

2015-01-28 Thread MRAB

On 2015-01-28 11:10, David Aldrich wrote:

Hi

I am just getting started with Python 3.3.3 and Kivy 1.8.

I am using the Kivy  development environment on Windows (open a command prompt 
and call kivy.bat).

With this minimal code:

import kivy
kivy.require('1.8.0')

from kivy.app import App
from kivy.uix.label import Label

class MyApp(App):
   def build(self):
 return Label(text='Hello World')

   if __name__ == '__main__':
 MyApp().run()

I get this error when I run it:

C:\python MinimalApplication.py
[INFO  ] Kivy v1.8.0
[INFO  ] [Logger  ] Record log in snip
[INFO  ] [Factory ] 157 symbols loaded
[DEBUG  ] [Cache   ] register kv.lang with limit=None, 
timeout=Nones
[DEBUG  ] [Cache   ] register kv.image with limit=None, 
timeout=60s
[DEBUG  ] [Cache   ] register kv.atlas with limit=None, 
timeout=Nones
[INFO  ] [Image   ] Providers: img_tex, img_dds, img_pygame, 
img_gif (img_pil ignored)
[DEBUG  ] [Cache   ] register kv.texture with limit=1000, 
timeout=60s
[DEBUG  ] [Cache   ] register kv.shader with limit=1000, 
timeout=3600s
[INFO  ] [Text] Provider: pygame
  Traceback (most recent call last):
File MinimalApplication.py, line 7, in module
  class MyApp(App):
File MinimalApplication.py, line 12, in MyApp
  MyApp().run()
  NameError: name 'MyApp' is not defined

How can I fix this please?


Unindent the 'if' statement. Currently, it's indented inside the class
definition, so MyApp isn't defined yet.

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


[issue23337] Run python with restricted rights

2015-01-28 Thread Ramchandra Apte

Ramchandra Apte added the comment:

BTW I think this is more of a support request than an issue.

I might be stating the obvious, but is there any firewall software installed?

--
nosy: +Ramchandra Apte

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



[issue15381] Optimize BytesIO to do less reallocations when written, similarly to StringIO

2015-01-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ping.

--

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



[issue23332] datetime.isoformat() - explicitly mark UTC string as such

2015-01-28 Thread mirabilos

mirabilos added the comment:

There’s another minor bug here: UTC should append “Z”, not “+00:00”, which 
other timezones at that offset can do.

Agreed about no timezone being “floating” time in many instances, e.g. the 
iCalendar format uses that.

--
nosy: +mirabilos

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



Beginner question - class definition error

2015-01-28 Thread David Aldrich
Hi

I am just getting started with Python 3.3.3 and Kivy 1.8.

I am using the Kivy  development environment on Windows (open a command prompt 
and call kivy.bat).

With this minimal code:

import kivy
kivy.require('1.8.0')

from kivy.app import App
from kivy.uix.label import Label

class MyApp(App):
  def build(self):
return Label(text='Hello World')

  if __name__ == '__main__':
MyApp().run()

I get this error when I run it:

C:\python MinimalApplication.py
[INFO  ] Kivy v1.8.0
[INFO  ] [Logger  ] Record log in snip
[INFO  ] [Factory ] 157 symbols loaded
[DEBUG  ] [Cache   ] register kv.lang with limit=None, 
timeout=Nones
[DEBUG  ] [Cache   ] register kv.image with limit=None, 
timeout=60s
[DEBUG  ] [Cache   ] register kv.atlas with limit=None, 
timeout=Nones
[INFO  ] [Image   ] Providers: img_tex, img_dds, img_pygame, 
img_gif (img_pil ignored)
[DEBUG  ] [Cache   ] register kv.texture with limit=1000, 
timeout=60s
[DEBUG  ] [Cache   ] register kv.shader with limit=1000, 
timeout=3600s
[INFO  ] [Text] Provider: pygame
 Traceback (most recent call last):
   File MinimalApplication.py, line 7, in module
 class MyApp(App):
   File MinimalApplication.py, line 12, in MyApp
 MyApp().run()
 NameError: name 'MyApp' is not defined

How can I fix this please?

Best regards

David

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


RE: Beginner question - class definition error

2015-01-28 Thread David Aldrich
 Unindent the 'if' statement. Currently, it's indented inside the class
 definition, so MyApp isn't defined yet.

Thanks very much. That fixed it.

Best regards

David
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: An object is an instance (or not)?

2015-01-28 Thread Mario Figueiredo
In article mailman.18203.1422424695.18130.python-l...@python.org, 
breamore...@yahoo.co.uk says...
 
 The thing that bothers me is that many people, some of them with maybe 
 20 years of Python experience, have repeatedly stated Python concepts 
 with respect to the terms class, instance and object.  Instead of 
 accepting their knowledge of the language and gracefully stepping back, 
 you've carried on until the twist of knots would make any boy scout proud.

Condescending much?

I'm not one to lower to arguments from authority. Sorry. Never have, 
never will. Neither I adopt such attitude on those programming languages 
in which I am myself an authoritative source. I respect knowledge as 
anyone else. But I also specifically asked for arguments that could show 
me the Python way. I have a desire to understand. It's not just a matter 
of accepting the word of someone who is more experienced than me. That 
does not do any good to anyone. I'm not trying to change anything, 
neither I'm a OOP fanatic like some tried to accuse me. I'm just trying 
to understand. Do *you* understand that?

I may have sounded ignorant to you. It's something I cannot avoid, 
because while I try to argue this issue, I do it from the position of 
someone who is still learning the Python language syntax and semantics. 
But I'm much more than what you may think. And I would like to be 
treated with a little more respect. Like you I'm a software developer 
and, probably like you, I have decades of software development as a 
profession on my back.

But some of the arguments in here (and yours too) have done very little 
to help me understand the language semantics on this particular issue. 
Purportedly, or perhaps innocently due to my clumsiness, some folks in 
here argue with little more than but a class object is an instance of 
'type'. They choose to ignore that class objects are clearly a special 
type of object unlike the instances they help define. Like in so many 
debates, there's unfortunately always a desire to ignore or avoid other 
side that is arguing with us.

Thankfully, I am now starting to understand the semantics. Folks like 
Ben, Steven or Ian (apologies to a couple others I am missing. Can't 
remember your names and having an hard time looking through past posts) 
have helped tremendously by leaving smugness aside, adopting an 
educational attitude towards a clearly confused person, and -- I would 
wager -- understanding that I'm asking questions, not trying to set new 
ways.

Don't feel so bothered by my person, sir. Just ignore me if that makes 
you feel better.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23338] PyErr_Format in ctypes uses invalid parameter

2015-01-28 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue23339] dict_values should be comparable with a set

2015-01-28 Thread ThiefMaster

New submission from ThiefMaster:

 d = {'1': '2'}
 {'1'}  d.keys()
False
 {'1'}  set(d.values())
False
 {'1'}  d.values()
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: unorderable types: set()  dict_values()


Same for e.g. the `-` operator.

Since dict_keys acts like a real set I think dict_values should do so, too. At 
least if all the values are hashable.

--
components: Library (Lib)
messages: 234888
nosy: ThiefMaster
priority: normal
severity: normal
status: open
title: dict_values should be comparable with a set
versions: Python 2.7, Python 3.4

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



[issue18813] Speed up slice object processing

2015-01-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

So may be close this issue as it doesn't affect performance?

--

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



Re: An object is an instance (or not)?

2015-01-28 Thread Gregory Ewing

Mario Figueiredo wrote:
An instance of an object is capable of doing so, per its 
class definitions. Whereas a Python class object is not.


 class Master:
def func(self):
pass

 class Sub(Master):
pass

 Sub.func()
TypeError: func() missing 1 required positional argument: 'self'


But Sub is not an *instance* of Master here, it's
a *subclass* of Master, which is quite a different
thing:

 Sub.__class__
class 'type'

To make Sub be an *instance* of Master, you need to
do this. (NOTE: This is Python 3 syntax; the same
thing can be done in Python 2, but the syntax is
slightly different.)

 class Master(type):
...  def func(self):
...   print(func of, self, called)
...
 class Sub(metaclass = Master):
...  pass
...
 Sub.__class__
class '__main__.Master'
 Sub.func()
func of class '__main__.Sub' called

So, you see, Python classes *can* participate in OOP
just as fully as any other object. You just need to
know how to do it correctly.

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


[issue23338] PyErr_Format in ctypes uses invalid parameter

2015-01-28 Thread Makoto Kato

Makoto Kato added the comment:

add fix for ctypes of 2.7 branch.

I don't know correct way to attach patch and process for patch.  (I am new 
commer).  So please let me know correct way if incorrect.

--
hgrepos: +294
keywords: +patch
Added file: http://bugs.python.org/file37890/py.patch

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



Re: Python is DOOMED! Again!

2015-01-28 Thread Ian Kelly
On Wed, Jan 28, 2015 at 8:04 AM, Mario Figueiredo mar...@gmail.com wrote:
 In article 54c83ab4$0$12982$c3e8da3$54964...@news.astraweb.com,
 steve+comp.lang.pyt...@pearwood.info says...

 Mario Figueiredo wrote:

  Static analysis cannot and should not clutter executable code.

 (1) It isn't clutter. The human reader uses that information as well as the
 compiler, interpreter, type-checker, IDE, text editor, correctness tester,
 etc.

 (2) Algol, Ada, Boo, C, C#, C++, Cobol, Cobra, D, F#, Fantom, Fortran, Go,
 Haskell, Java, Julia, Kotlin, Oberon, Pascal, Rust, Scala and dozens
 (hundreds?) of other languages disagree with you.


 Sorry. Somehow I missed this post. Only realized now from the Skip
 answer.

 This is simply not true!

 For most of the strongly typed languages (e.g. static typed languages)

Python is a strongly typed language. It checks types at runtime and
does little implicit type conversion. Strong != static.

 in that list -- C, C++, C# and Scala, the ones I know best from that
 list -- require little to no annotations in the code (and certainly no
 new explicit function or class based syntax) in order for static
 analysers to perform their thing, except perhaps on the most exotic
 static analysers.

The languages you cite don't require extra type annotations because
they already have the types in the function signatures. Here's an
example function signature in Scala:

def addInt( a:Int, b:Int ) : Int

How is that significantly different from a Python function that uses
the proposed annotations?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23335] _ssl.c cannot be compiled with older versions of OpenSSL

2015-01-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 16f982f93a47 by Benjamin Peterson in branch 'default':
ifdef our way to compatibility with old openssl (closes #23335)
https://hg.python.org/cpython/rev/16f982f93a47

New changeset 1addc4f0f10c by Benjamin Peterson in branch '2.7':
ifdef our way to compatibility with old openssl (closes #23335)
https://hg.python.org/cpython/rev/1addc4f0f10c

--
nosy: +python-dev
resolution:  - fixed
stage: needs patch - resolved
status: open - closed

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



Re: An object is an instance (or not)?

2015-01-28 Thread random832
On Wed, Jan 28, 2015, at 01:59, Ben Finney wrote:
 You have no justification to claim that, and it's hostile and dismissive
 to claim it so assertively.

Sorry about that - I was tired and had just read through the whole
thread at once.

 I'll freely admit to finding “'Foo' object” ambiguous. It can reasonably
 be interpreted to mean either “a 'Foo' object” (⇒ “an object of class
 'Foo'”), or “the 'Foo' object” (⇒ “the object referred to by the name
 'Foo'”). The error message which inspired this thread needs improvement,
 as I've said already.

Most objects do not have an idea of their name, though. Assigning an
object to a new name doesn't change the object, either.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-28 Thread Chris Angelico
On Thu, Jan 29, 2015 at 5:47 AM, Chris Kaynor ckay...@zindagigames.com wrote:
 I use Google Drive for it for all the stuff I do at home, and use SVN
 for all my personal projects, with the SVN depots also in Drive. The
 combination works well for me, I can transfer between my desktop and
 laptop freely, and have full revision history for debugging issues.

I just do everything in git, no need for either Drive or something as
old as SVN. Much easier. :)

Using a more modern source control system (I'd normally recommend
people use either git or Mercurial, though there are a few others that
are also viable) saves you the trouble of oops, I'm offline and can't
reach the Subversion server and other issues.

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


Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-28 Thread Devin Jeanpierre
On Wed, Jan 28, 2015 at 1:40 PM, Chris Angelico ros...@gmail.com wrote:
 On Thu, Jan 29, 2015 at 5:47 AM, Chris Kaynor ckay...@zindagigames.com 
 wrote:
 I use Google Drive for it for all the stuff I do at home, and use SVN
 for all my personal projects, with the SVN depots also in Drive. The
 combination works well for me, I can transfer between my desktop and
 laptop freely, and have full revision history for debugging issues.

 I just do everything in git, no need for either Drive or something as
 old as SVN. Much easier. :)

Git doesn't help if you lose your files in between commits, or if you
lose the entire directory between pushes.

-- Devin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SUBMIT ACCEPT button - Python - beautifulsoap

2015-01-28 Thread lazar . michael22
On Wednesday, January 28, 2015 at 8:36:59 AM UTC-8, peter.n...@gmail.com wrote:
 I am totally new to Python and please accept my apologies upfront for 
 potential newbie errors. I am trying to parse a 'simple' web page: 
 http://flow.gassco.no/
 
 When opening the page first time in my browser I need to confirm TC with an 
 accept button. After accepting TC I would like to scrape some data from that 
 follow up page. It appears that when opening in a browser directly 
 http://flow.gassco.no/acceptDisclaimer I would get around that TC.
 But not when I open the URL via beautifulsoap
 
 My parsing/scraping tool is implemented in bs, but I fail to parse the 
 content as I am not getting around TC. When printing response.text from 
 BS, I get below code. How do I get around this form for accepting terms  
 conditions so that I can parse/scrape data from that page?
 
 Here is what I am doing:
 
 #!/usr/bin/env python 
 import requests 
 import bs4 
 index_url='http://flow.gassco.no/acceptDisclaimer'
 
 def get_video_page_urls(): 
 response = requests.get(index_url) 
 soup = bs4.BeautifulSoup(response.text) 
 return soup 
 print(get_video_page_urls()) 
 
 
 
 PRINTOUT from response.text:
 
form action=acceptDisclaimer method=get
  input class=accept type=submit value=Accept/
  input class=decline name=decline onclick=window.location 
 ='http://www.gassco.no' type=button value=Decline/
  /form/div/div/div/div/div
 
 script type=text/javascript
 var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-30727768-1']);
 _gaq.push(['_trackPageview']);
 
 (function() {
 var ga = document.createElement('script'); ga.type = 
 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 
 'http://www') + '.google-analytics.com/ga.js';
 var s = document.getElementsByTagName('script')[0]; 
 s.parentNode.insertBefore(ga, s);
 })();
 
 /script

Try clearing your browser cookies and then reopening the page, it should spit 
you back to the TOC screen. 

You can use the Session class to keep track of your cookies between requests:

with requests.Session() as s:

# Request sessionid cookie and store it in the current session
response = s.get('http://flow.gassco.no')

# Subsequent gets will now include the session cookie 
response = s.get('http://flow.gassco.no/acceptDisclaimer')

A good place to start when debugging something like this is to open up the 
developer tools in your browser (F12 in chrome/firefox) and observe the GET 
requests that get sent out as you click on different buttons.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue22931] cookies with square brackets in value

2015-01-28 Thread Dan LaMotte

Changes by Dan LaMotte lamott...@gmail.com:


--
nosy: +dlamotte

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



[issue2292] Missing *-unpacking generalizations

2015-01-28 Thread Neil Girdhar

Neil Girdhar added the comment:

Fixed a couple bugs and added a test.

Incremented the magic number.

--
Added file: http://bugs.python.org/file37896/starunpack24.diff

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



Re: multiprocessing module backport from 3 to 2.7 - spawn feature

2015-01-28 Thread Devin Jeanpierre
On Wed, Jan 28, 2015 at 10:06 AM, Skip Montanaro
skip.montan...@gmail.com wrote:
 On Wed, Jan 28, 2015 at 7:07 AM, Andres Riancho andres.rian...@gmail.com
 wrote:
 The feature I'm specially interested in is the ability to spawn
 processes [1] instead of forking, which is not present in the 2.7
 version of the module.

 Can you explain what you see as the difference between spawn and fork in
 this context? Are you using Windows perhaps? I don't know anything obviously
 different between the two terms on Unix systems.

On Unix, if you fork without exec*, and had threads open, threads
abruptly terminate, resulting in completely broken mutex state etc.,
which leads to deadlocks or worse if you try to acquire resources in
the forked child process. So in such circumstances, multiprocessing
(in 2.7) is not a viable option. But 3.x adds a feature, spawn, that
lets you fork+exec instead of just forking.

I too would be interested in such a backport. I considered writing
one, but haven't had a strong enough need yet.

-- Devin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why zip64_limit defined as 131 -1?

2015-01-28 Thread Ian Kelly
On Wed, Jan 28, 2015 at 11:53 AM, jesse chat2je...@gmail.com wrote:
 should not it be 132 -1(4g)?

 normal zip archive format should be able to support 4g file.

Bugs can be filed at http://bugs.python.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23341] Issue parsing valid cookie

2015-01-28 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
resolution:  - duplicate
stage:  - resolved
superseder:  - cookies with square brackets in value

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



Re: write file to a server

2015-01-28 Thread Chris Angelico
On Thu, Jan 29, 2015 at 5:05 AM, Mark Lawrence breamore...@yahoo.co.uk wrote:
 Windows will accept forward slashes in path names.

Normally, yes. Does that work for UNC names too?
//server/share/pathname ? In any case, that's an alternative solution
to the same problem.

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


[issue23304] Unused Superclass in calendar.py

2015-01-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I suppose that calendar.error is here for compatibility. It is an alias to 
ValueError, so that errors raised by the calendar module can be catched with 
the except calendar.error: statement. Making calendar.error different class 
will likely break user code. I am inclined to reject this patch.

--
nosy: +serhiy.storchaka

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



[issue23341] Issue parsing valid cookie

2015-01-28 Thread Dan LaMotte

Dan LaMotte added the comment:

Yes, this is a duplicate of that bug.  Sorry.

--
status: open - closed

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



[issue22931] cookies with square brackets in value

2015-01-28 Thread Demian Brecht

Demian Brecht added the comment:

Ping for review/commit.

--

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



[issue2292] Missing *-unpacking generalizations

2015-01-28 Thread Neil Girdhar

Neil Girdhar added the comment:

Just need to fix the parser now.  Minimal example:

 parser.sequence2st(parser.expr({1}).totuple())
Traceback (most recent call last):
  File stdin, line 1, in module
parser.ParserError: Expected node type 12, got 302.

--

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



Re: why zip64_limit defined as 131 -1?

2015-01-28 Thread Chris Angelico
On Thu, Jan 29, 2015 at 5:53 AM, jesse chat2je...@gmail.com wrote:
 should not it be 132 -1(4g)?

 normal zip archive format should be able to support 4g file.

 thanks

131-1 is the limit for a signed 32-bit integer. You'd have to look
into the details of the zip file format to see whether that's the
official limit or not; it might simply be that some (un)archivers have
problems with 2GB files, even if the official stance is that it's
unsigned.

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


[issue23342] run() - unified high-level interface for subprocess

2015-01-28 Thread Thomas Kluyver

Thomas Kluyver added the comment:

Updated patch following Gregory's suggestions:

- The check_returncode parameter is now called check. The method on 
CompletedProcess is still check_returncode, though.
- Clarified the docs about args
- CalledProcessError and TimeoutExceeded gain a stdout property as an alias of 
output

Ethan: to combine stdout and stderr in check_output, you need to pass 
stderr=subprocess.STDOUT - it doesn't assume you want that.

I did consider having a simplified interface so you could pass e.g. 
capture='combine', or capture='stdout', but I don't think the brevity is worth 
the loss of flexibility.

--
Added file: http://bugs.python.org/file37899/subprocess_run2.patch

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



[issue13697] python RLock implementation unsafe with signals

2015-01-28 Thread STINNER Victor

STINNER Victor added the comment:

FYI I proposed a fix for eventlet to fix eventlet with Python 3 when 
monkey-patching is used:
https://github.com/eventlet/eventlet/pull/187

The change forces the Python implementation of RLock, which is compatible with 
eventlet monkey-patching. The Python implementation of RLock gets the thread 
identifier from the monkey-patched threading module, whereas the C 
implementation calls directly a C function to get the identifier which is 
incompatible with eventlet.

If the Python implementation is simply dropped, eventlet may uses its own 
implementation (copy/paste code from older Python version).

--

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



Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-28 Thread Steven D'Aprano
sohcahto...@gmail.com wrote:

 I recently finished my CS degree, and I had more than one professor say
 that they won't take My computer crashed and I lost everything! as an
 excuse for not being able to turn in homework.  

How about My computer crashed and died and now I can't get to Dropbox to
access my files?

My computer got infected by ransomware which encrypted all my data files
and blocks access to Dropbox.

One of my housemates torrented a Linux tarball, and the MPAA wrongly
identified it as a movie file. Purely on their say-so, my ISP disabled my
account and banned me from the Internet. But all is not lost, if I move 45
miles away, I can sign up with a different ISP!

Some dude I've never seen before gate-crashed our party and was smoking
pot, and the police raided us and seized my computer and everybody's
phones. My lawyer tells me the raid was illegal and if spend two or three
hundred thousand dollars in legal fees, I'll probably be able to get my
computer back within eight years or so.

My dog ate my USB stick.

:-)




-- 
Steven

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


[issue18982] Add tests for CLI of the calendar module

2015-01-28 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy: +berker.peksag

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



[issue23304] Unused Superclass in calendar.py

2015-01-28 Thread Berker Peksag

Berker Peksag added the comment:

Looks like error was unused since 
https://hg.python.org/cpython/rev/acdc0b9a6c78#l2.48 (see also  
https://hg.python.org/cpython/rev/6ee380349c84/ for time.gmtime()). LGTM.

--
nosy: +berker.peksag
stage:  - commit review

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



[issue23342] run() - unified high-level interface for subprocess

2015-01-28 Thread Ethan Furman

Ethan Furman added the comment:

I haven't checked the code, but does check_output and friends combine stdout 
and stderr when ouput=PIPE?

--

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



[issue23333] asyncio: call protocol.connection_lost() when the creation of transport failed

2015-01-28 Thread STINNER Victor

STINNER Victor added the comment:

 The call to loop.add_reader() should maybe be scheduled after the call to 
 connection_made()? To ensure that protocol methods (feed_data) are not called 
 before connection_made() has been called.

Fixed by:
---
changeset:   94360:1b35bef31bf8
branch:  3.4
tag: tip
user:Victor Stinner victor.stin...@gmail.com
date:Thu Jan 29 00:36:51 2015 +0100
files:   Lib/asyncio/selector_events.py 
Lib/test/test_asyncio/test_selector_events.py
description:
asyncio: Fix _SelectorSocketTransport constructor

Only start reading when connection_made() has been called:
protocol.data_received() must not be called before protocol.connection_made().
---

Other fix related to this issue:
---
changeset:   94358:1da90ebae442
branch:  3.4
parent:  94355:263344bb2107
user:Victor Stinner victor.stin...@gmail.com
date:Thu Jan 29 00:35:56 2015 +0100
files:   Lib/asyncio/sslproto.py Lib/test/test_asyncio/test_sslproto.py
description:
asyncio: Fix SSLProtocol.eof_received()

Wake-up the waiter if it is not done yet.
---

--

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



Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-28 Thread Steven D'Aprano
Devin Jeanpierre wrote:

 On Wed, Jan 28, 2015 at 1:40 PM, Chris Angelico ros...@gmail.com wrote:
 On Thu, Jan 29, 2015 at 5:47 AM, Chris Kaynor ckay...@zindagigames.com
 wrote:
 I use Google Drive for it for all the stuff I do at home, and use SVN
 for all my personal projects, with the SVN depots also in Drive. The
 combination works well for me, I can transfer between my desktop and
 laptop freely, and have full revision history for debugging issues.

 I just do everything in git, no need for either Drive or something as
 old as SVN. Much easier. :)
 
 Git doesn't help if you lose your files in between commits, 

Sure it does? You just lose the changes made since the previous commit, but
that's no different from restoring from backup. The restored file is only
as up to date as the last time a backup was taken.


 or if you 
 lose the entire directory between pushes.

Then restore from wherever you are pushing to.

But as Devin says, any backup strategy that requires the user to make a
backup is untrustworthy. I'm hoping that the next generation of DVCSs will
support continuous commits, the next generation of editors support
continuous saves, and the only time you need interact with the editor
(apart from, you know, actual editing) is to tell it start a new branch
now.



-- 
Steven

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


Re: Python is DOOMED! Again!

2015-01-28 Thread Steven D'Aprano
Ian Kelly wrote:

 On Wed, Jan 28, 2015 at 8:04 AM, Mario Figueiredo mar...@gmail.com
 wrote:
 In article 54c83ab4$0$12982$c3e8da3$54964...@news.astraweb.com,
 steve+comp.lang.pyt...@pearwood.info says...

 Mario Figueiredo wrote:

  Static analysis cannot and should not clutter executable code.

 (1) It isn't clutter. The human reader uses that information as well as
 the compiler, interpreter, type-checker, IDE, text editor, correctness
 tester, etc.

 (2) Algol, Ada, Boo, C, C#, C++, Cobol, Cobra, D, F#, Fantom, Fortran,
 Go, Haskell, Java, Julia, Kotlin, Oberon, Pascal, Rust, Scala and dozens
 (hundreds?) of other languages disagree with you.


 Sorry. Somehow I missed this post. Only realized now from the Skip
 answer.

 This is simply not true!

 For most of the strongly typed languages (e.g. static typed languages)
 
 Python is a strongly typed language. It checks types at runtime and
 does little implicit type conversion. Strong != static.
 
 in that list -- C, C++, C# and Scala, the ones I know best from that
 list -- require little to no annotations in the code (and certainly no
 new explicit function or class based syntax) in order for static
 analysers to perform their thing, except perhaps on the most exotic
 static analysers.
 
 The languages you cite don't require extra type annotations because
 they already have the types in the function signatures. Here's an
 example function signature in Scala:
 
 def addInt( a:Int, b:Int ) : Int
 
 How is that significantly different from a Python function that uses
 the proposed annotations?

Ian, that's obvious. Just open your eyes:

Scala
def addInt( a:Int, b:Int ) : Int

Python
def addInt( a:int, b:int ) - int:


They're COMPLETELY different. In Scala they are *type declarations*, not
annotations. We're talking about annotations, not declarations. They're as
different as cheese and a very slightly different cheese. Do try to keep
up.

*wink*


-- 
Steven

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


[issue23340] armv7l C++ exceptions issue

2015-01-28 Thread Eric V. Smith

Eric V. Smith added the comment:

I agree with David that this isn't the right venue.

That said, the likely problem is that Python's main() is written in C, not C++, 
so some needed runtime support for exceptions is not getting initialized.

--
nosy: +eric.smith
resolution:  - not a bug

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



[issue13697] python RLock implementation unsafe with signals

2015-01-28 Thread Lothsahn

Lothsahn added the comment:

I am using Python 2.6.5 (we will be upgrading to Python 2.7.9 soon) and I 
recently ran into this bug.

If I do any locking in a signal handler with RLocks, the entire system can 
deadlock.  I'm using this to serialize my IO so we don't have mismatched lines 
in our logs.  It looks like RLock was implemented in C in 3.2.  While I don't 
care about the performance benefits of that rewrite, having a non-deadlocking 
RLock implementation would be nice.

Not sure if this issue can be fixed in 2.7, but it would be nice.

C RLock implementation here:
http://bugs.python.org/issue3001

--
nosy: +Lothsahn

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



[issue23342] run() - unified high-level interface for subprocess

2015-01-28 Thread Gregory P. Smith

Gregory P. Smith added the comment:

Ethan: check_output combines them when stdout=subprocess.STDOUT is passed (
https://docs.python.org/3.5/library/subprocess.html#subprocess.STDOUT).
Never pass stdout=PIPE or stderr= PIPE to call() or check*() methods as
that will lead to a deadlock when a pipe buffer fills up.  check_output()
won't even allow you pass in stdout as it needs to set that to PIPE
internally, but you could still do the wrong thing and pass stderr=PIPE
without it warning you.

the documentation tells people not to do this.  i don't recall why we
haven't made it warn or raise when someone tries.  (but that should be a
separate issue/change)

On Wed Jan 28 2015 at 3:30:59 PM Ethan Furman rep...@bugs.python.org
wrote:


 Ethan Furman added the comment:

 I haven't checked the code, but does check_output and friends combine
 stdout and stderr when ouput=PIPE?

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue23342
 ___


--

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



Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-28 Thread sohcahtoa82
On Wednesday, January 28, 2015 at 3:13:36 PM UTC-8, Chris Kaynor wrote:
 On Wed, Jan 28, 2015 at 3:01 PM, Devin Jeanpierre
 jeanpierr...@gmail.com wrote:
  On Wed, Jan 28, 2015 at 2:02 PM, Chris Angelico ros...@gmail.com wrote:
  On Thu, Jan 29, 2015 at 8:52 AM, Devin Jeanpierre
  jeanpierr...@gmail.com wrote:
  Git doesn't help if you lose your files in between commits, or if you
  lose the entire directory between pushes.
 
  So you commit often and push immediately. Solved.
  I distrust any backup strategy that requires explicit action by the
  user. I've seen users fail too often. (Including myself.)
 
 That tends to be my opinion and experience as well :)
 
 And that is where Drive is quite nice: its an automatic backup to an
 off-site backup that requires no user action. Having some form of
 source control is still needed however, as you don't get all the nice
 history with Drive, and don't have the atomic updates - typically,
 every save will be uploaded, even if that change itself will break
 everything as you haven't made the required changes to other files.
 
 Chris K

I'd definitely store all of my programming projects in a Google Drive if I 
wasn't already using Dropbox.

I recently finished my CS degree, and I had more than one professor say that 
they won't take My computer crashed and I lost everything! as an excuse for 
not being able to turn in homework.  Dropbox and Google Drive are both free, 
easy to use, and will keep several versions of your files so you can even use 
the excuse that your most recent save got corrupted.

Also, it was really nice to easily be able to save my work on my laptop, finish 
it on my desktop, and then print it from a school computer without dealing with 
a thumb drive.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23333] asyncio: add a new Protocol.connection_failed() method

2015-01-28 Thread STINNER Victor

STINNER Victor added the comment:

New patch which adds a new Protocol.connection_failed() method.

The method is called when the creation of the transport failed, ie. when the 
connection failed, on SSL handshake failure for example.

The patch also closes the transport on connection failure (avoid a 
ResourceWarning with patch of the issue #23243).

--
title: asyncio: call protocol.connection_lost() when the creation of transport 
failed - asyncio: add a new Protocol.connection_failed() method
Added file: http://bugs.python.org/file37900/connection_failed.patch

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



[issue23342] run() - unified high-level interface for subprocess

2015-01-28 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


--
nosy: +vadmium

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



Re: Python is DOOMED! Again!

2015-01-28 Thread Chris Angelico
On Thu, Jan 29, 2015 at 11:37 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 They're as
 different as cheese and a very slightly different cheese. Do try to keep
 up.

As different as brie and camembert?

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


[issue23285] PEP 475 - EINTR handling

2015-01-28 Thread Ned Deily

Ned Deily added the comment:

It turns out the times are not important; the hangup is the default size of the 
socket buffers on OS X and possibly BSD in general.  In my case, the send and 
receive buffers are 8192, which explains why the chunks written are so small.  
I somewhat arbitrarily changed the sizes of the buffers in _test_send with:

rd.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, support.SOCK_MAX_SIZE // 3)
wr.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, support.SOCK_MAX_SIZE // 3)

The results were:

test_send (__main__.SocketEINTRTest) ... rd SO_RCVBUF default was 8192, wr 
SO_SNDBUF default was 8192
len(data) = 50331651
 sent = 5592405, written = 5592405
 chunk = 5592405, total read = 5592405
 chunk = 5592405, total read = 11184810
 chunk = 5592405, total read = 16777215
 sent = 16777215, written = 22369620
 chunk = 5592405, total read = 22369620
 chunk = 5592405, total read = 27962025
 chunk = 5592405, total read = 33554430
 chunk = 5592405, total read = 39146835
 sent = 22369620, written = 44739240
 chunk = 5592405, total read = 44739240
 sent = 5592411, written = 50331651
 chunk = 5592405, total read = 50331645
 chunk = 6, total read = 50331651
ok
test_sendall (__main__.SocketEINTRTest) ... rd SO_RCVBUF default was 8192, wr 
SO_SNDBUF default was 8192
len(data) = 50331651
 chunk = 5592405, total read = 5592405
 chunk = 5592405, total read = 11184810
 chunk = 5592405, total read = 16777215
 chunk = 5592405, total read = 22369620
 chunk = 5592405, total read = 27962025
 chunk = 5592405, total read = 33554430
 chunk = 5592405, total read = 39146835
 chunk = 5592405, total read = 44739240
 sent = None, written = 50331651
 chunk = 5592405, total read = 50331645
 chunk = 6, total read = 50331651
ok
test_sendmsg (__main__.SocketEINTRTest) ... rd SO_RCVBUF default was 8192, wr 
SO_SNDBUF default was 8192
len(data) = 50331651
 sent = 5592405, written = 5592405
 chunk = 5592405, total read = 5592405
 chunk = 5592405, total read = 11184810
 chunk = 5592405, total read = 16777215
 chunk = 5592405, total read = 22369620
 chunk = 5592405, total read = 27962025
 sent = 27962025, written = 33554430
 chunk = 5592405, total read = 33554430
 chunk = 5592405, total read = 39146835
 chunk = 5592405, total read = 44739240
 sent = 16777221, written = 50331651
 chunk = 5592405, total read = 50331645
 chunk = 6, total read = 50331651
ok

I dunno if a value that large will work in all environments, so the code to 
call setsockopt might need to be smarter.

--

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



[issue23334] http.client refactor

2015-01-28 Thread Demian Brecht

Demian Brecht added the comment:

On 2015-01-27 7:34 PM, R. David Murray wrote:
 Quantifying largely will be important.

Understandably. In terms of the public API, all changes should be purely
additive and 100% backwards compatible. largely is referring to some
of the private API that has been removed (i.e. _output and _send_output)
as they're no longer needed. This should also hold true for upcoming
changes as well.

--

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



[issue13128] httplib debuglevel on CONNECT doesn't print response headers

2015-01-28 Thread Demian Brecht

Demian Brecht added the comment:

New patch removes unrelated changes.

--
Added file: http://bugs.python.org/file37892/issue13128_3.patch

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



[issue23334] http.client refactor

2015-01-28 Thread R. David Murray

R. David Murray added the comment:

Although they are private interfaces we may decide we need a deprecation 
release before dropping them.  Sometimes what we do in cases like this is go 
ahead and make the changes, but also provide the old methods via a 
backward-compatible shim and have them emit deprecation warnings.  (I haven't 
looked at your specific changes, and unfortunately probably won't have time to 
do so :(

--

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



Open file in default app and exit in Windows

2015-01-28 Thread stephen . boulet
I am using the following to open a file in its default application in Windows 7:

from subprocess import call

filename = 'my file.csv'
call('%s' % filename, shell=True)

This still leaves a python process hanging around until the launched app is 
closed. Any idea how to get around?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23334] http.client refactor

2015-01-28 Thread Demian Brecht

Demian Brecht added the comment:

On 2015-01-28 7:41 AM, R. David Murray wrote:
 Although they are private interfaces we may decide we need a deprecation 
 release before dropping them.  Sometimes what we do in cases like this is go 
 ahead and make the changes, but also provide the old methods via a 
 backward-compatible shim and have them emit deprecation warnings.

That makes sense. If it's decided that's the path that should be
pursued, I'll add them in once the functional/test/doc changes have all
been made. Thanks for the heads up.

--

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



Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-28 Thread Chris Angelico
On Thu, Jan 29, 2015 at 8:52 AM, Devin Jeanpierre
jeanpierr...@gmail.com wrote:
 Git doesn't help if you lose your files in between commits, or if you
 lose the entire directory between pushes.

So you commit often and push immediately. Solved.

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


[issue23343] operator precedence table for `not x` has an operand, while the others do not

2015-01-28 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
stage:  - resolved

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



Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-28 Thread Chris Kaynor
On Wed, Jan 28, 2015 at 3:01 PM, Devin Jeanpierre
jeanpierr...@gmail.com wrote:
 On Wed, Jan 28, 2015 at 2:02 PM, Chris Angelico ros...@gmail.com wrote:
 On Thu, Jan 29, 2015 at 8:52 AM, Devin Jeanpierre
 jeanpierr...@gmail.com wrote:
 Git doesn't help if you lose your files in between commits, or if you
 lose the entire directory between pushes.

 So you commit often and push immediately. Solved.
 I distrust any backup strategy that requires explicit action by the
 user. I've seen users fail too often. (Including myself.)

That tends to be my opinion and experience as well :)

And that is where Drive is quite nice: its an automatic backup to an
off-site backup that requires no user action. Having some form of
source control is still needed however, as you don't get all the nice
history with Drive, and don't have the atomic updates - typically,
every save will be uploaded, even if that change itself will break
everything as you haven't made the required changes to other files.

Chris K
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23343] operator precedence table for `not x` has an operand, while the others do not

2015-01-28 Thread Hobs

New submission from Hobs:

Shouldn't the [operator precedence 
table](https://docs.python.org/3.4/reference/expressions.html#operator-precedence),
 5th row, 1st column, just say `not` rather than `not` x? The other rows 
are identified by the keyword for the operator and don't include any 
operand(s). Is there some other expression that includes `not` that should have 
a different position in the precedence table?

--
assignee: docs@python
components: Documentation
messages: 234919
nosy: Hobson.Lane, docs@python
priority: normal
severity: normal
status: open
title: operator precedence table for `not x` has an operand, while the others 
do not
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5

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



[issue23343] operator precedence table for `not x` has an operand, while the others do not

2015-01-28 Thread Hobs

Hobs added the comment:

Just noticed the other entries for not. Not a bug.

--
resolution:  - not a bug
status: open - closed

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



Re: unicode question

2015-01-28 Thread Albert-Jan Roskam


On Wed, Jan 28, 2015 8:21 AM CET Terry Reedy wrote:

On 1/27/2015 12:17 AM, Rehab Habeeb wrote:
 Hi there python staff
 does python support arabic language for texts ? and what to do if it
 support it?
 i wrote hello in Arabic using codeskulptor and the powershell just for
 testing and the same error appeared( a sytanx error in unicode)!!

I do not know how complete the support is, but this is copied from 3.4.2, 
which uses tcl/tk 8.6.
 t = الحركات
 for c in t: print(c)  # Prints rightmost char above first
ا
ل
ح
ر
ك
ا
ت

Wow, I never knew this was so clever. Is that with or without an RTL marker?


The following StackOverflow question and response indicate that there may b 
more issue, but it was asked before tcl/tk 8.6 was available, so the answer 
may be partially obsolete.


-- Terry Jan Reedy


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

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


[issue23342] run() - unified high-level interface for subprocess

2015-01-28 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
nosy: +r.david.murray

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



[issue23342] run() - unified high-level interface for subprocess

2015-01-28 Thread Gregory P. Smith

Changes by Gregory P. Smith g...@krypto.org:


--
assignee:  - gregory.p.smith
nosy: +gregory.p.smith

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



  1   2   >