Re: What is the semantics meaning of 'object'?
On Wed, Jun 26, 2013 at 11:07 AM, Mark Janssen dreamingforw...@gmail.com wrote: Combining two integers lets you make a Rational. Ah, but what is going to group them together? You see you've already gotten seduced. Python already uses a set to group them together -- it's called a Dict and it's in every Class object. When you inherit a set to make a Rational, you're making the statement (to the interpreter, if nothing else) that a Rational is-a set. No you don't *inherit* a set to make a Rational, although you gain a set to make it. It's a subtle thing, because at the center of it articulates the very difference between a piece of data and a container to hold that data. Or is the container the data? C++ already solves this di-lemma. It made class which is exactly like a struct, but hides all it's data members. That critical distinction makes all the difference. I don't know how many people on the list really appreciate it. I certainly don't. In fact, I hardly use class in C++ these days - I just use struct and let the members be public. How is that significant? The thing you're completely missing, though, is that NONE of what you're saying has anything to do with inheritance or super(). It's all composition. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? fwhile
On Wed, Jun 26, 2013 at 10:47 AM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Tue, 25 Jun 2013 17:20:43 +1000, Neil Hodgson nhodg...@iinet.net.au declaimed the following: jim...@aol.com: Syntax: fwhile X in ListY and conditionZ: There is precedent in Algol 68: for i from 0 to n while safe(i) do .. od The REXX variant would be do for i = 0 to n while safe(i) ... end Basically one has an optional for clause ( for index = initial to end by step ), and one has an optional while/until clause -- Hmm, wonder if some interpreters would parse both while and until G. I need to install Regina Rexx on this new machine... Modulo the 'for' keyword, which is superfluous there. Here's a test script I knocked up on my OS/2 box back home: /* */ do i=0 to 9 while safe(i) say i is safe end exit safe: procedure return arg(1)\=6 The \= in the last line is the REXX not-equal operator, like != in Python. This outputs: 0 is safe 1 is safe 2 is safe 3 is safe 4 is safe 5 is safe and then terminates. It's pretty clean; the DO/END construct defines a block, and may optionally execute it more than once. With no arguments, it just creates a block that executes once (equivalent to C's braces); valid args include FOREVER (infinitely loop), WHILE condition (iterate while condition is true), UNTIL condition (execute once, then check condition, iterate while condition is false - like a do/while in C), var=value (eg I=1 - set var to value, then increment by 1 or by the BY value, continue forever or until the TO value), and possibly another that's slipped my mind. Aside from FOREVER, which stands alone, they're completely independent. But that's syntax, lots of it. What I'd like to see in Python is simply a bit of flexibility in the rule about newlines. The for/if construct in Python could be exactly the same as it now is, only with the two statements on one line, and it would look very similar to the existing notation. I can already one-line a simple statement: for i in range(10): print(i) I just can't put in an if: for i in range(10): if i%3: print(i) SyntaxError: invalid syntax But I can, as long as I use expression-if: for i in range(10): print(i) if i%3 else None Seriously, I can use Perl-style notation to achieve this. Does that seem right to you? *boggle* ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
Michael Torrie於 2013年6月20日星期四UTC+8下午2時01分11秒寫道: But since the LISP never really got a form beyond S-expressions, leaving us with lots of parenthesis everywhere, Python wins much as the Hitchhiker's Guide to the Galaxy wins. Yep, a list is mutable even it's empty. But constant integers, floats, strings, and None is immutable. The variables in a function of python with default parameters which could be mutable or immutable. def fun1( x, alist=[]): alist.append(x*x) return alist ## valid def fun2(x, alist=None): if alist==None: alist=[] alist.append(x*x) return alist # kind of boring to show the name binding mechanism of objects # in Python in different usages -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie EOL while scanning string literal
On Tue, 25 Jun 2013 17:05:50 -0700, willlewis965 wrote: thanks man you answered my questions very clear, btw do you know of a place where I can learn python I know some tutorials but are 2. something and I'm using 3.3 and I've been told they are different. Try here: http://mail.python.org/mailman/listinfo/tutor -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Returned mail: Data format error
This email was blocked due to unallowed file attachment. From: python-list@python.org Recipient: jbee...@lakeport.k12.ca.us Subject: Returned mail: Data format error Date: Wed, 26 Jun 2013 16:30:55 +0800 powered by mxHero -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
On Tue, 25 Jun 2013 16:19:08 -0700, Mark Janssen wrote: Well you've been spoiled by all the work that came before you. The issue now is not to go back to the machine so much as to tear down and build up again from raw materials, objects of more and more complexity where very complex meta-objects upon meta-objects can be built until the whole of human knowledge can be contained. It must be a wonderful view from way, way up there, but how do you breathe? http://www.joelonsoftware.com/items/2008/05/01.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
On Tue, Jun 25, 2013 at 7:07 PM, Mark Janssen dreamingforw...@gmail.com wrote: When you inherit a set to make a Rational, you're making the statement (to the interpreter, if nothing else) that a Rational is-a set. No you don't *inherit* a set to make a Rational, although you gain a set to make it. Okay, then. Since you started this discussion from the topic of multiple inheritance I was under the impression that you were talking about using inheritance to construct Rationals from integers and sets. Evidently that is not so, and you've been talking about composition all along, in which case I have no idea how any of this relates to your original suggestion of putting superclasses in charge of their subclasses. -- http://mail.python.org/mailman/listinfo/python-list
Re: A certainl part of an if() structure never gets executed.
Am 12.06.2013 03:46 schrieb Rick Johnson: On Tuesday, June 11, 2013 8:25:30 PM UTC-5, nagia@gmail.com wrote: is there a shorter and more clear way to write this? i didnt understood what Rick trie to told me. My example included verbatim copies of interactive sessions within the Python command line. You might understand them better if you open the Python command line and type each command in one-by-one. Here is an algoritm that explains the process: open_command_window() whilst learning or debugging: type_command() press_enter() observe_output() if self.badder.is_full: take_potty_break() close_command_window() with command_window(): whilst learning or debugging: type_command() press_enter() observe_output() if self.badder.is_full: take_potty_break() looks nicer. SCNR Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? fwhile
On Wednesday, 26 June 2013 01:40:22 UTC+1, Dennis Lee Bieber wrote: (hmmm, does any language have a continue that can go to the next iteration of an outer loop?) Perl allows next with a label: perldoc -f next next LABEL nextThe next command is like the continue statement in C; it starts the next iteration of the loop: LINE: while (STDIN) { next LINE if /^#/; # discard comments #... } Note that if there were a continue block on the above, it would get executed even on discarded lines. If the LABEL is omitted, the command refers to the innermost enclosing loop. -- http://mail.python.org/mailman/listinfo/python-list
Is this PEP-able? fwhile
On Tuesday, June 25, 2013 9:30:54 PM UTC+5:30, Ian wrote: In my experience the sorts of people who preach one exit point are also all about defining preconditions and postconditions and proving that the postconditions follow from the preconditions. I think that the two are linked, because the one exit point rule makes those sorts of proofs simpler. Ah! utopia! For every one who knows about pre/post/invariant conditions, there are 10 who follow goto-statement-is-harmful like a religious edict. I just checked and MISRA-C 2012 now allows gotos in specific, limited circumstances. I think it was the MISRA-C 1998 standard that caused all this trouble. So if MISRA now allows goto, why not Python :) -- http://mail.python.org/mailman/listinfo/python-list
problem with pyinstaller: packaging multiple python scripts under Mac
This is my first time using pyinstaller. My goal is to build an .app in Mac. The app is basically a GUI written in PySide, and I have about 7 different Python scripts + 1 .png file. The main file calls 4 of the files, and the 4 files will call the rest of the 2 files repeatedly. The .png file is nothing but the window logo. Could someone help me with some diagnosis? I do not know what went wrong. I searched a lot of documentations online, i.e., change spec, add import, ... etc. but my app still doesn't run. FYI, Pyinstaller could generate an app for me, but there are two issues: 1. Icon is not changed for the app. 2. App crashes when opened. My Python version is 2.7.5 and I am using PyInstaller-2.0. Here is my code for packaging: python pyinstaller.py --onefile --windowed --name=MyApplication -i ~/Documents/AASource/icon.ico ~/Documents/AASource/Scripts/main_file.py Here is the spec file: # -*- mode: python -*- a = Analysis(['/Users/boxuancui/Documents/AASource/Scripts/main_file.py'], pathex=['/Users/boxuancui/Documents/pyinstaller-2.0'], hiddenimports=[], hookspath=None) pyz = PYZ(a.pure) exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, name=os.path.join('dist', 'MyApplication'), debug=False, strip=None, upx=True, console=False , icon='/Users/boxuancui/Documents/AASource/icon.ico') app = BUNDLE(exe, name=os.path.join('dist', 'MyApplication.app')) Here is part of the crash message: Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x54d8 Thanks in advance! Any help will be appreciated! Best, Boxuan-- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
On Wed, Jun 26, 2013 at 9:19 AM, Mark Janssen dreamingforw...@gmail.com wrote: Did you ever hear of the Glass Bead Game? Yeah, it's Magic: The Gathering and its counters. http://www.wizards.com/magic/magazine/Article.aspx?x=mtgcom/daily/mr195 :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
On Mon, Jun 24, 2013 at 7:37 AM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: What do you mean with not a participant in the past? As far as I can see his first appearance was in dec 2011. That is over a year ago. It also seems that he always find people willing to engage with him. Is how the group treats him not also an aspect in deciding whether he belongs or not? Although it's true that he's been around for a while, it has in my mind only been very recently that his posts have started to become a problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about pickle
f.seek(0) really does the trick. Danke sehr, Phu On Tue, Jun 25, 2013 at 6:47 AM, Peter Otten __pete...@web.de wrote: Phu Sam wrote: I have a method that opens a file, lock it, pickle.load the file into a dictionary. I then modify the status of a record, then pickle.dump the dictionary back to the file. The problem is that the pickle.dump never works. The file never gets updated. def updateStatus(self, fp, stn, status): f = open(fp, 'rw+') fcntl.flock(f.fileno(),fcntl.LOCK_EX | fcntl.LOCK_NB) tb = pickle.load(f) self.modifyDict(tb, stn, status) f.seek(0) pickle.dump(tb, f) fcntl.flock(f.fileno(),fcntl.LOCK_UN) f.close() What could be the problem here? pickle.load() moves the file position to the end of the (first) pickle. pickle.dump() writes the modified dict starting at the current position. You end up with two versions of the dict, but you'll only ever read the first. The fix is to go back to the start of the file with f.seek(). What mode should I use to open the file to allow both pickle.load and pickle.dump? Assuming that the file already exists when updateStatus() is invoked for the first time: r+b. I usually open the file twice, once for reading and then for writing, but I guess that would interfere with locking. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Limit Lines of Output
On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: On 25 June 2013 21:22, Bryan Britten britten.br...@gmail.com wrote: Ah, I always forget to mention my OS on these forums. I'm running Windows. Supposedly, Windows has more [http://superuser.com/questions/426226/less-or-more-in-windows], Yes, but less is more than more. For Linux+less; this works: from subprocess import Popen, PIPE less = Popen(less, stdin=PIPE) less.stdin.write(b\n.join(This is line number {}.format(i).encode(UTF-8) for i in range(1000))) less.wait() Cheers, Gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) My web page: http://coyoteden.dyndns-free.com:85/gene is up! My views http://www.armchairpatriot.com/What%20Has%20America%20Become.shtml Campbell's Law: Nature abhors a vacuous experimenter. A pen in the hand of this president is far more dangerous than 200 million guns in the hands of law-abiding citizens. -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a name for a deployment framework...
On Tuesday 2013 June 25 19:16, Dave Angel wrote: On 06/25/2013 03:38 PM, Stig Sandbeck Mathisen wrote: jonathan.slend...@gmail.com writes: Any suggestions for a good name, for a framework that does automatic server deployments? Yet Another Deployment Framework? -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
Op 26-06-13 00:27, Mark Janssen schreef: The main problem is getting to the top/end of the call chain. Classic example is with __init__, but the same problem can also happen with other calls. Just a crazy theory, but would it be possible to construct a black-holing object that, for any given method name, returns a dummy function that ignores its args? (Other forms of attribute lookup aren't going to be a problem, I think, so this can be just methods/functions.) Then you just subclass from that all the time, instead of from object itself, and you should be able to safely call super's methods with whatever kwargs you haven't yourself processed. Would that work? Caveat: I have not done much with MI in Python, so my idea may be complete balderdash. Here's how it *should* be made: the most superest, most badassed object should take care of its children. New instances should automatically call up the super chain (and not leave it up to the subclasses), so that the parent classes can take care of the chil'en. When something goes wrong the parent class has to look in and see what's wrong. Could you explain why you think it should work this way? Maybe illustrate how this is supposed to work. Let take a very simple example. We have a class that works with a stream (anything with a write method). class Streamer: def __init__(self, strm): ... Now we find that we very often use this class with a file, so we would like to make a subclass that takes a filename as parameter. This we would write somehow like the following class Filer(Streamer): def __init__(self, fn): fl = open(fn, a+) super.__init__(fl) ... Can you explain how this example should be written en work as you view things? -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a name for a deployment framework...
In article mailman.3887.1372243292.3114.python-l...@python.org, xDog Walker thud...@gmail.com wrote: On Tuesday 2013 June 25 19:16, Dave Angel wrote: On 06/25/2013 03:38 PM, Stig Sandbeck Mathisen wrote: jonathan.slend...@gmail.com writes: Any suggestions for a good name, for a framework that does automatic server deployments? Yet Another Deployment Framework? Boring. How about Soliloquy. Then the project tag line could be, Deploy, or not deploy, that is the question. For further hack value, require that all pull requests to the project be done entirely in iambic pentameter: for host in hosts: deploy(the_code).remote() -- http://mail.python.org/mailman/listinfo/python-list
Re: Limit Lines of Output
On Tue, 25 Jun 2013 14:39:30 -0600, Ian Kelly wrote: On Tue, Jun 25, 2013 at 2:31 PM, Joshua Landau joshua.landau...@gmail.com wrote: On 25 June 2013 21:22, Bryan Britten britten.br...@gmail.com wrote: Ah, I always forget to mention my OS on these forums. I'm running Windows. Supposedly, Windows has more [http://superuser.com/questions/426226/less-or-more-in-windows], For Linux+less; this works: from subprocess import Popen, PIPE less = Popen(less, stdin=PIPE) less.stdin.write(b\n.join(This is line number {}.format(i).encode(UTF-8) for i in range(1000))) less.wait() Or simply: $ python my_script.py | less It works the same way in Windows: C:\ python my_script.py | more this would be my approach it leaves it to the user to decide what to do with the output (they may even decide to write it to a file themselves) and obeys to very good principles 1) Do not re-invent the wheel. 2) do only 1 job but do it well. -- Every morning, I get up and look through the 'Forbes' list of the richest people in America. If I'm not there, I go to work -- Robert Orben -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? fwhile
On 26 Jun 2013 11:45, jim...@aol.com wrote: On Tuesday, June 25, 2013 9:30:54 PM UTC+5:30, Ian wrote: In my experience the sorts of people who preach one exit point are also all about defining preconditions and postconditions and proving that the postconditions follow from the preconditions. I think that the two are linked, because the one exit point rule makes those sorts of proofs simpler. Ah! utopia! For every one who knows about pre/post/invariant conditions, there are 10 who follow goto-statement-is-harmful like a religious edict. I just checked and MISRA-C 2012 now allows gotos in specific, limited circumstances. I think it was the MISRA-C 1998 standard that caused all this trouble. So if MISRA now allows goto, why not Python :) What is the matter? Just use the goto module... -- http://mail.python.org/mailman/listinfo/python-list
Re: unresolved externals error message building pywin32 for pypy
On Wednesday, 26 June 2013 12:57:32 UTC+10, jasonve...@gmail.com wrote: Hi, I get an unresolved externals error message when building pywin32 for pypy, as listed below. Both are the latest versions, amauryfa-pywin32-pypy-2a1da51e8152 and pypy-2.0.2. As per build requirements, VS2012 and Win 7 SDD are installed. Not sure what the error msg indicates, but maybe the python lib in linking is missing some required functions. Possible cause of error may be a python installation on the same system (build could be using python lib instead of pypy lib), but python has been removed from path, and its folder name has also been changed. Any suggestions as to cause of this error would be appreciated. Thanks Jason H: pypy setup.py install Building pywin32 2.7.217.1 running install running build running build_py running build_ext Found version 0x601 in H:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\SDKDDKVER.H building 'pywintypes' extension ... H:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:H:\pypy-2.0.2\include /LIBPATH:build\temp.win32-2.7\Release /LIBPATH:H:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib advapi32.lib user32.lib ole32.lib oleaut32.lib /EXPORT:initpywintypes build\temp.win32-2.7\Release\win32\src\PyACL.obj build\temp.win32-2.7\Release\win32\src\PyDEVMODE.obj build\temp.win32-2.7\Release\win32\src\PyHANDLE.obj build\temp.win32-2.7\Release\win32\src\PyIID.obj build\temp.win32-2.7\Release\win32\src\PyLARGE_INTEGER.obj build\temp.win32-2.7\Release\win32\src\PyOVERLAPPED.obj build\temp.win32-2.7\Release\win32\src\PySECURITY_ATTRIBUTES.obj build\temp.win32-2.7\Release\win32\src\PySECURITY_DESCRIPTOR.obj build\temp.win32-2.7\Release\win32\src\PySID.obj build\temp.win32-2.7\Release\win32\src\PyTime.obj build\temp.win32-2.7\Release\win32\src\PyUnicode.obj build\temp.win32-2.7\Release\win32\src\PyWAVEFORMATEX.obj build\temp.win32-2.7\Release\win32\sr c\PyWinTypesmodule.obj /OUT:build\lib.win32-2.7\pywin32_system32\pywintypes27.dll /IMPLIB:build\temp.win32-2.7\Release\win32\src\pywintypes27.lib /MANIFEST /MANIFEST:NO /MACHINE:x86 /BASE:0x1e7a /DEBUG /PDB:build\temp.win32-2.7\Release\pywintypes.pdb Creating library build\temp.win32-2.7\Release\win32\src\pywintypes27.lib and object build\temp.win32-2.7\Release\win32\src\pywintypes27.exp PyTime.obj : error LNK2001: unresolved external symbol _PyArg_ParseTuple PyWAVEFORMATEX.obj : error LNK2001: unresolved external symbol _PyArg_ParseTuple PyWinTypesmodule.obj : error LNK2019: unresolved external symbol _PyArg_ParseTuple referenced in function int __cdecl PyWinGlobals_Ensure(void) (?PyWinGlobals_Ensure@@YAHXZ) PyOVERLAPPED.obj : error LNK2001: unresolved external symbol _PyArg_ParseTuple PySECURITY_ATTRIBUTES.obj : error LNK2001: unresolved external symbol _PyArg_ParseTuple PySECURITY_DESCRIPTOR.obj : error LNK2001: unresolved external symbol _PyArg_ParseTuple ... build\lib.win32-2.7\pywin32_system32\pywintypes27.dll : fatal error LNK1120: 106 unresolved externals error: command 'H:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\link.exe' failed with exit status 1120 Solution found: the setup.py-generated link.exe command omitted python27.lib for some reason. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? fwhile
On Tue, 25 Jun 2013 12:39:53 -0400, jimjhb wrote: I just checked and MISRA-C 2012 now allows gotos in specific, limited circumstances. I think it was the MISRA-C 1998 standard that caused all this trouble. So if MISRA now allows goto, why not Python :) [humour] You can! Just use the goto module. It supports both GOTO and COMEFROM: http://entrian.com/goto/ [/humour] But seriously... GOTO works best in low-level languages. It is not very well suited for high-level languages like Python. Nevertheless, Python does support a very limited number of flow control statements which are like GOTO in some ways: `break` and `continue` for jumping out of loops, and exceptions which are cheap enough to be used as flow control. You cannot jump into the middle of a function, or to an arbitrary line, or into a loop. But this is a good thing -- languages that allow unrestricted flow control end up with unmaintainable spaghetti code. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
class factory question
I am extending a parser and need to create many classes that are all subclassed from the same object (defined in an external library). When my module is loaded I need all the classes to be created with a particular name but the behavior is all the same. Currently I have a bunch of lines like this: class Vspace(Base.Command): pass class Boldpath(Base.Command): pass There are a bunch of lines like that. Is there a better way? Something like newclasses = ['Vspace', 'Boldpath', ... ] for name in newclasses: tmp = type(name, (Base.Command,) {}) tmp.__name__ = name Is there a more pythonic way? thanks, --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? fwhile
On 2013-06-25, rusi rustompm...@gmail.com wrote: On Tuesday, June 25, 2013 9:30:54 PM UTC+5:30, Ian wrote: In my experience the sorts of people who preach one exit point are also all about defining preconditions and postconditions and proving that the postconditions follow from the preconditions. I think that the two are linked, because the one exit point rule makes those sorts of proofs simpler. Ah! utopia! For every one who knows about pre/post/invariant conditions, there are 10 who follow goto-statement-is-harmful like a religious edict. The one-exit-point rule is helpful for tracking entry and exit invariants. But in my view it shouldn't be followed when it makes code worse. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? fwhile
On Wednesday, June 26, 2013 6:03:39 PM UTC+5:30, Steven D'Aprano wrote: On Tue, 25 Jun 2013 12:39:53 -0400, jimjhb wrote: I just checked and MISRA-C 2012 now allows gotos in specific, limited circumstances. I think it was the MISRA-C 1998 standard that caused all this trouble. So if MISRA now allows goto, why not Python :) [humour] You can! Just use the goto module. It supports both GOTO and COMEFROM: [/humour] Comefrom + inverted inheritance ! Are we ready for a new pep? -- http://mail.python.org/mailman/listinfo/python-list
Re: class factory question
Tim wrote: I am extending a parser and need to create many classes that are all subclassed from the same object (defined in an external library). When my module is loaded I need all the classes to be created with a particular name but the behavior is all the same. Currently I have a bunch of lines like this: class Vspace(Base.Command): pass class Boldpath(Base.Command): pass There are a bunch of lines like that. Is there a better way? Something like newclasses = ['Vspace', 'Boldpath', ... ] for name in newclasses: tmp = type(name, (Base.Command,) {}) tmp.__name__ = name Is there a more pythonic way? What is your objection against that approach? By the way, I don't think you need tmp.__name__ = name -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? fwhile
On Tuesday, June 25, 2013 10:09:53 PM UTC+5:30, jim...@aol.com wrote: I just checked and MISRA-C 2012 now allows gotos in specific, limited circumstances. I think it was the MISRA-C 1998 standard that caused all this trouble. So if MISRA now allows goto, why not Python :) Not sure who is joking and who serious in this thread. As for who started the 'goto-trouble' it was 30 years before 1998 http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html -- http://mail.python.org/mailman/listinfo/python-list
Re: class factory question
On Wednesday, June 26, 2013 9:39:12 AM UTC-4, Peter Otten wrote: Tim wrote: I am extending a parser and need to create many classes that are all subclassed from the same object (defined in an external library). When my module is loaded I need all the classes to be created with a particular name but the behavior is all the same. Currently I have a bunch of lines like this: class Vspace(Base.Command): pass class Boldpath(Base.Command): pass There are a bunch of lines like that. Is there a better way? Something like newclasses = ['Vspace', 'Boldpath', ... ] for name in newclasses: tmp = type(name, (Base.Command,) {}) tmp.__name__ = name Is there a more pythonic way? What is your objection against that approach? By the way, I don't think you need tmp.__name__ = name I am not completely understanding the type function I guess. Here is an example from the interpreter: In [1]: class MyClass(object): ...: pass ...: In [2]: type('Vspace', (MyClass,), {}) Out[2]: __main__.Vspace In [3]: x = Vspace() --- NameError Traceback (most recent call last) C:\Python27\Scripts\ipython-input-3-a82f21420bf3 in module() 1 x = Vspace() NameError: name 'Vspace' is not defined In [4]: Vspace = type('Vspace', (MyClass,), {}) In [5]: x = Vspace() In [6]: type(x) Out[6]: __main__.Vspace I don't understand how to make `Vspace` usable for creating instances later (line 3) when I just call `type`; that is why I thought adding the `__name__` attribute would work. Hmm, now I know that doesn't work either: In [8]: del Vspace In [9]: m = type('Vspace', (MyClass,), {}) In [10]: m.__name__ = 'Vspace' In [11]: x = Vspace() --- NameError Traceback (most recent call last) C:\Python27\Scripts\ipython-input-11-a82f21420bf3 in module() 1 x = Vspace() NameError: name 'Vspace' is not defined In [11]: m Out[12]: __main__.Vspace Maybe this is too much trouble just to save a few lines (~50) of code. thanks, --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: io module and pdf question
Le mardi 25 juin 2013 06:18:44 UTC+2, jyou...@kc.rr.com a écrit : Would like to get your opinion on this. Currently to get the metadata out of a pdf file, I loop through the guts of the file. I know it's not the greatest idea to do this, but I'm trying to avoid extra modules, etc. Adobe javascript was used to insert the metadata, so the added data looks something like this: XYZ:colorList=DarkBlue,Yellow With python 2.7, it successfully loops through the file contents and I'm able to find the line that contains XYZ:colorList. However, when I try to run it with python 3, it errors: File /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/codecs.py, line 300, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 10: invalid continuation byte I've done some research on this, and it looks like encoding it to latin-1 works. I also found that if I use the io module, it will work on both python 2.7 and 3.3. For example: -- import io import os pdfPath = '~/Desktop/test.pdf' colorlistData = '' with io.open(os.path.expanduser(pdfPath), 'r', encoding='latin-1') as f: for i in f: if 'XYZ:colorList' in i: colorlistData = i.split('XYZ:colorList')[1] break print(colorlistData) -- As you can tell, I'm clueless in how exactly this works and am hoping someone can give me some insight on: 1. Is there another way to get metadata out of a pdf without having to install another module? 2. Is it safe to assume pdf files should always be encoded as latin-1 (when trying to read it this way)? Is there a chance they could be something else? 3. Is the io module a good way to pursue this? Thanks for your help! Jay --- Forget latin-1. There is nothing wrong in attempting to get such information by reading a pdf file in a binary mode. What is important is to know and be aware about what you are searching and to do the work correctly. A complete example with the pdf file, hypermeta.pdf, I produced which contains the string abcé€ as Subject metadata. pdf version: 1.4 producer: LaTeX with hyperref package (personal comment: xdvipdfmx) Python 3.2 with open('hypermeta.pdf', 'rb') as fo: ... r = fo.read() ... p1 = r.find(b'Subject') p1 4516 p2 = r.find(b'', p1) p2 4548 rr = r[p1:p2+1] rr b'Subjectfeff00610062006300e920ac' rrr = rr[len(b'Subject'):-1] rrr b'feff00610062006300e920ac' # decoding the information rrr = rrr.decode('ascii') rrr 'feff00610062006300e920ac' i = 0 a = [] while i len(rrr): ... t = rrr[i:i+4] ... a.append(t) ... i += 4 ... a ['feff', '0061', '0062', '0063', '00e9', '20ac'] b = [(int(e, 16) for e in a] File eta last command, line 1 b = [(int(e, 16) for e in a] ^ SyntaxError: invalid syntax # oops, error allowed b = [int(e, 16) for e in a] b [65279, 97, 98, 99, 233, 8364] c = [chr(e) for e in b] c ['\ufeff', 'a', 'b', 'c', 'é', '€'] # result d = ''.join(c) d '\ufeffabcé€' d = d[1:] d 'abcé€' As Christian Gollwitzer pointed out, not all objects in a pdf are encoded in that way. Do not expect to get the contain, the text is that way. When built with the Unicode technology, the text of a pdf is composed with a *unique* set of abstract ID's, constructed with the help of the unicode code points table and with the properties of the font (OpenType) used in that pdf, this is equivalent to the utf8/16/32 transformers in plain unicode. Luckily for the crowd, in 2103, there are people (devs) who are understanding the coding of characters, unicode and how to use it. jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? fwhile
On Jun 26, 2013, at 7:49 AM, Fábio Santos fabiosantos...@gmail.com wrote: On 26 Jun 2013 11:45, jim...@aol.com wrote: On Tuesday, June 25, 2013 9:30:54 PM UTC+5:30, Ian wrote: In my experience the sorts of people who preach one exit point are also all about defining preconditions and postconditions and proving that the postconditions follow from the preconditions. I think that the two are linked, because the one exit point rule makes those sorts of proofs simpler. Ah! utopia! For every one who knows about pre/post/invariant conditions, there are 10 who follow goto-statement-is-harmful like a religious edict. I just checked and MISRA-C 2012 now allows gotos in specific, limited circumstances. I think it was the MISRA-C 1998 standard that caused all this trouble. So if MISRA now allows goto, why not Python :) What is the matter? Just use the goto module... Wondered when that would be mentioned. Personally, I've never found that much use for GoTo, but as old timers know, that same module adds the Come_From entry point, which is priceless. ;-) Bill-- http://mail.python.org/mailman/listinfo/python-list
Re: class factory question
Tim wrote: I am not completely understanding the type function I guess. Here is an example from the interpreter: In [1]: class MyClass(object): ...: pass ...: In [2]: type('Vspace', (MyClass,), {}) Out[2]: __main__.Vspace In [3]: x = Vspace() --- NameError Traceback (most recent call last) C:\Python27\Scripts\ipython-input-3-a82f21420bf3 in module() 1 x = Vspace() NameError: name 'Vspace' is not defined No, you are not understanding how Python namespaces work ;) To get a Vspace in the global namespace you'd have to bind that name Vspace = type(...) which defeats your plan of mass creation of such names. The clean way to cope with the situation is to use a dict: classnames = [Vspace, ...] classes = {name: type(name, ...) for name in classnames} Then you can access the Vspace class with classes[Vspace] If that is inconvenient for your usecase you can alternatively update the global (module) namespace: globals().update((name, type(name, ...) for name in classnames) For example: class A(object): pass ... globals().update((n, type(n, (A,), {})) for n in [Beta, Gamma]) Beta class '__main__.Beta' issubclass(Beta, A) True -- http://mail.python.org/mailman/listinfo/python-list
Re: class factory question
On Wednesday, June 26, 2013 10:46:55 AM UTC-4, Peter Otten wrote: Tim wrote: I am not completely understanding the type function I guess. Here is an example from the interpreter: No, you are not understanding how Python namespaces work ;) To get a Vspace in the global namespace you'd have to bind that name Vspace = type(...) which defeats your plan of mass creation of such names. The clean way to cope with the situation is to use a dict: classnames = [Vspace, ...] classes = {name: type(name, ...) for name in classnames} Then you can access the Vspace class with classes[Vspace] If that is inconvenient for your usecase you can alternatively update the global (module) namespace: globals().update((name, type(name, ...) for name in classnames) For example: class A(object): pass ... globals().update((n, type(n, (A,), {})) for n in [Beta, Gamma]) Beta class '__main__.Beta' issubclass(Beta, A) True Thank you for that great explanation. That is exactly what I needed to know! What a fantastic group this is. --Tim -- http://mail.python.org/mailman/listinfo/python-list
Re: class factory question
On 26 June 2013 15:46, Peter Otten __pete...@web.de wrote: The clean way to cope with the situation is to use a dict: classnames = [Vspace, ...] classes = {name: type(name, ...) for name in classnames} Then you can access the Vspace class with classes[Vspace] If that is inconvenient for your usecase you can alternatively update the global (module) namespace: globals().update((name, type(name, ...) for name in classnames) For example: class A(object): pass ... globals().update((n, type(n, (A,), {})) for n in [Beta, Gamma]) Beta class '__main__.Beta' issubclass(Beta, A) True I would say if a dict isn't good, there are still some cases where you might not want to use globals. I _might_ do: import sys from types import ModuleType # As before newclasses = ['Vspace', 'Boldpath', and so on, and yes, these all become variables] little_classes = {name: type(name, (int,), {}) for name in newclasses} # Make a module module_for_little_classes = ModuleType(module_for_little_classes, All the things) module_for_little_classes.__dict__.update(little_classes) # Hack it in there! sys.modules[module_for_little_classes] = module_for_little_classes # Now we can undo all import module_for_little_classes as mlc mlc.Vspace mlc.Boldpath ... # And undo all our hard work avoiding globals(): from module_for_little_classes import * Vspace Boldpath So, why avoid globals()? 1) Linters don't like globals() 2) Urm... it's ugly? 3) Ur... -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
On 25/06/2013 23:57, Chris Angelico wrote: On Wed, Jun 26, 2013 at 8:38 AM, Mark Janssen dreamingforw...@gmail.com wrote: Combining integers with sets I can make a Rational class and have infinite-precision arithmetic, for example. Combining two integers lets you make a Rational. Python integers are already infinite-precision. Or are you actually talking of using machine words and sets as your fundamental? Also, you need an ordered set - is the set {5,3} greater or less than the set {2} when you interpret them as rationals? One must assume, I suppose, that any one-element set represents the integer 1, because any number divided by itself is 1. Is the first operand 3/5 or 5/3? You could use Kuratowski ordered pairs: http://en.wikipedia.org/wiki/Ordered_pair#Kuratowski_definition Not that doing so would be sensible, of course. I don't know much about low-level data structures but it seems obvious that it's much easier to implement an ordered container type than an unordered set on a computer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Limit Lines of Output
On 25 June 2013 22:48, Gene Heskett ghesk...@wdtv.com wrote: On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: I did not. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
On Thu, Jun 27, 2013 at 1:16 AM, Rotwang sg...@hotmail.co.uk wrote: On 25/06/2013 23:57, Chris Angelico wrote: On Wed, Jun 26, 2013 at 8:38 AM, Mark Janssen dreamingforw...@gmail.com wrote: Combining integers with sets I can make a Rational class and have infinite-precision arithmetic, for example. Combining two integers lets you make a Rational. Python integers are already infinite-precision. Or are you actually talking of using machine words and sets as your fundamental? Also, you need an ordered set - is the set {5,3} greater or less than the set {2} when you interpret them as rationals? One must assume, I suppose, that any one-element set represents the integer 1, because any number divided by itself is 1. Is the first operand 3/5 or 5/3? You could use Kuratowski ordered pairs: http://en.wikipedia.org/wiki/Ordered_pair#Kuratowski_definition Not that doing so would be sensible, of course. I don't know much about low-level data structures but it seems obvious that it's much easier to implement an ordered container type than an unordered set on a computer. Yeah, I don't think Mark is much concerned about implementing things on actual computers, somehow :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: class factory question
Joshua Landau wrote: I would say if a dict isn't good, there are still some cases where you might not want to use globals. I _might_ do: # Make a module module_for_little_classes = ModuleType(module_for_little_classes, All the things) module_for_little_classes.__dict__.update(little_classes) Hm, from within module_for_little_classes that is globals(). To illustrate: import __main__ as main globals() is main.__dict__ True Also, I'd spell module.__dict__ vars(module). That said I agree that it's a good idea to use a dedicated module (not necessarily created on the fly) for those dynamically generated classes. -- http://mail.python.org/mailman/listinfo/python-list
Re: Limit Lines of Output
On Thu, Jun 27, 2013 at 1:24 AM, Joshua Landau joshua.landau...@gmail.com wrote: On 25 June 2013 22:48, Gene Heskett ghesk...@wdtv.com wrote: On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: I did not. Beg pardon? It looked like an accurate citation to me - you quoted the OP's second post, then added the line beginning Supposedly. That's what Gene quoted, so I'm not understanding this rejection. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Limit Lines of Output
On Wed, 26 Jun 2013 16:24:56 +0100, Joshua Landau wrote: On 25 June 2013 22:48, Gene Heskett ghesk...@wdtv.com wrote: On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: I did not. Unless there are two people called Joshua Landau with email address joshua.landau...@gmail.com, I'm afraid that you did. Here's the email that started the subthread, by Bryan Britten: http://mail.python.org/pipermail/python-list/2013-June/650697.html Your, or possibly your evil doppelganger's, reply to Bryan: http://mail.python.org/pipermail/python-list/2013-June/650698.html Followed by Gene's reply to your reply: http://mail.python.org/pipermail/python-list/2013-June/650750.html And your, or your evil doppelganger's, reply to Gene: http://mail.python.org/pipermail/python-list/2013-June/650773.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Limit Lines of Output
On Wednesday, June 26, 2013 8:54:56 PM UTC+5:30, Joshua Landau wrote: On 25 June 2013 22:48, Gene Heskett wrote: On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: I did not. I guess Joshua is saying that saying ≠ opining [Or is he opining?] -- http://mail.python.org/mailman/listinfo/python-list
re.finditer() skips unicode into selection
I am using the following Highlighter class for Spell Checking to work on my QTextEdit. class Highlighter(QSyntaxHighlighter): pattern = ur'\w+' def __init__(self, *args): QSyntaxHighlighter.__init__(self, *args) self.dict = None def setDict(self, dict): self.dict = dict def highlightBlock(self, text): if not self.dict: return text = unicode(text) format = QTextCharFormat() format.setUnderlineColor(Qt.red) format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline) unicode_pattern=re.compile(self.pattern,re.UNICODE|re.LOCALE) for word_object in unicode_pattern.finditer(text): if not self.dict.spell(word_object.group()): print word_object.group() self.setFormat(word_object.start(), word_object.end() - word_object.start(), format) But whenever I pass unicode values into my QTextEdit the re.finditer() does not seem to collect it. When I pass I am a नेपाली into the QTextEdit. The output is like this: I I I a I am I am I am a I am a I am a I am a I am a I am a I am a I am a It is completely ignoring the unicode. What might be the issue. I am new to PyQt and regex. Im using Python 2.7 and PyQt4. -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't feed the troll...
Op 25-06-13 17:56, ru...@yahoo.com schreef: On 06/24/2013 07:37 AM, Antoon Pardon wrote: Op 23-06-13 16:29, ru...@yahoo.com schreef: On 06/21/2013 01:32 PM, Antoon Pardon wrote: Op 19-06-13 23:13, ru...@yahoo.com schreef: [...] I put forward what I thought was a rational way of thinking about the problem that balances the competing desires. You reject it with, too easy to neglect the concerns of individuals or small groups. I point out that I don't see any way of satisfying the concerns of individuals or small groups and the majority and you accuse me going for debating points. But you didn't even go to the trouble of trying to find out what those concerns would be and how strong people feel about them. You just took your assumptions about those concerns for granted and proceeded from there. Second having concerns and showing them are two different things. It may be possible that you have a lot of concerns for the flamers, that doesn't mean you actually showed them. If you need some sort of public show, then I will publicly state that I too have been very frustrated with many of Nikos' posts and I am greatly sympathetic to the desire to tell the SOB to go take a flying fuck. That not withstanding I believe that responding that way does not help anything and is destructive. You really should learn the difference between telling and showing. So I'll stand by my statement that you show no concern for the discomfort of this group you are contributing to. As far as I can see your only concern is make them behave according to the solution, you arrived at without any contribution from themselves. The operative part there is: as far as you can see. There seem to be two options. Either there is nothing to see or I missed it, in which case this would have been a very good opportunity to point it out. You are free to ignore that and do what you want. But remember to tell me again how *I* have no concern for others. This is not a competion in trying to make the other look less concerned than the other. I don't care whether or not you have concerns for others. I'm just pointing out that if you would like to influence the behaviour of others in a direction you'd prefer, then you'd better show concerns about what drives them to that behaviour. I don't think that just stating that some group of people are somehow to blame according to some conclusion that logically followed from assumptions you could choose, and that thus this other group has to adapt its behaviour while you can carry on as usual, is such a good way either. You persist in presenting the situation as though I am just making things up to justify a proposal that makes my own use of the group easier. You ignore the rational I gave and the experience of countless internet users over the history of the internet. Why should I care about the rational you gave. It is based on your own assumptions, on how you weight the possible outcomes against each other. Someone who doesn't care about trolls or even may enjoy observing a heated exchange may come to an entirely different conclusion on what behaviour is good for the group in case he extrapolated his own preferences on the group. And you may not have purposely made things up to justify your proposal, but how you went about it, that is probably what you actually did. Because that is what we as humans generally do in this kind of situations. You sure seem awful careful with regards to someone you view as being outside the volition of the group while a the same time seeing nothing wrong with being very blunt about some subgroup of people you seem to consider inside the volition of the group, and whith which you have a particular problem. Again this is an no concern argument. Additionally... It is wrong. I've not advocated being very blunt to those who aggravate the situation by responding to trolling with flames and more aggression. I didn't mean you advocated it. I mean that you actually have been blunt about these people. These are you words: ] The primary problem is a (relatively small) number of people ] who respond to every post by Nikos with a barrage of insults, ] demands, (what they think are) witty repartee, hints intended ] to make Nikos learn something, useless (to Nikos) links, ] new threads to discuss the Nikos problem, and other trash ] that is far more obnoxious that anything Nikos posts and just ] serves to egg him on. Now as far as I am concerned you can be as blunt as you want to be. I just don't understand why you think you should be so careful to Nikos, while at the same time you saw no need for careful wording here. A disproportionate number of your arguments above are that I am not concerned about those (including you) who are deeply frustrated with Nikos' bad behavior. No, I point out that your behaviour doesn't *show* any such concern. First, what my internal emotions (concern) are or are not is irrelevant -- what I have expressed in my
Re: Is this PEP-able? fwhile
Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Mon, 24 Jun 2013 19:01:11 -0700 (PDT), rusi rustompm...@gmail.com declaimed the following: On Tuesday, June 25, 2013 3:08:57 AM UTC+5:30, Chris Angelico wrote: On Tue, Jun 25, 2013 at 5:52 AM, wrote: (NOTE: Many people are being taught to avoid 'break' and 'continue' at all costs... Why? Why on earth should break/continue be avoided? Because breaks and continues are just goto-in-disguise? Because GOTO is a wild-card, capable of redirecting to anywhere; whereas break can only go to the exit of the loop (and in languages with labeled loops, possibly the exit of an outermost loop -- cf: Ada), and continue can only go to the next iteration of the loop (hmmm, does any language have a continue that can go to the next iteration of an outer loop?) Bash: continue: continue [n] Resume for, while, or until loops. Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop. If N is specified, resumes the Nth enclosing loop. Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: re.finditer() skips unicode into selection
On 6/26/2013 3:18 PM, akshay.k...@gmail.com wrote: I am using the following Highlighter class for Spell Checking to work on my QTextEdit. class Highlighter(QSyntaxHighlighter): pattern = ur'\w+' def __init__(self, *args): QSyntaxHighlighter.__init__(self, *args) self.dict = None def setDict(self, dict): self.dict = dict def highlightBlock(self, text): if not self.dict: return text = unicode(text) format = QTextCharFormat() format.setUnderlineColor(Qt.red) format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline) unicode_pattern=re.compile(self.pattern,re.UNICODE|re.LOCALE) for word_object in unicode_pattern.finditer(text): if not self.dict.spell(word_object.group()): print word_object.group() self.setFormat(word_object.start(), word_object.end() - word_object.start(), format) But whenever I pass unicode values into my QTextEdit the re.finditer() does not seem to collect it. When I pass I am a नेपाली into the QTextEdit. The output is like this: I I I a I am I am I am a I am a I am a I am a I am a I am a I am a I am a It is completely ignoring the unicode. The whole text is unicode. It is ignoring the non-ascii, as you asked it to with re.LOCALE. With 3.3.2: import re pattern = re.compile(r'\w+', re.LOCALE) text = I am a नेपाली for word in pattern.finditer(text): print(word.group()) I am a Delete ', re.LOCALE' and the following are also printed: न प ल There is an issue on the tracker about the vowel marks in नेपाली being mis-seen as word separators, but that is another issue. Lesson: when you do not understand output, simplify code to see what changes. Separating re issues from framework issues is a big step in that direction. ? What might be the issue. I am new to PyQt and regex. Im using Python 2.7 and PyQt4. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: re.finditer() skips unicode into selection
On 26/06/2013 20:18, akshay.k...@gmail.com wrote: I am using the following Highlighter class for Spell Checking to work on my QTextEdit. class Highlighter(QSyntaxHighlighter): In Python 2.7, the re module has a somewhat limited idea of what a word character is. It recognises 'DEVANAGARI LETTER NA' as a letter, but 'DEVANAGARI VOWEL SIGN E' as a diacritic. The pattern ur'(?u)\w+' will therefore split नेपाली into 3 parts. pattern = ur'\w+' def __init__(self, *args): QSyntaxHighlighter.__init__(self, *args) self.dict = None def setDict(self, dict): self.dict = dict def highlightBlock(self, text): if not self.dict: return text = unicode(text) format = QTextCharFormat() format.setUnderlineColor(Qt.red) format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline) The LOCALE flag is for locale-sensitive 1-byte per character bytestrings. It's rarely useful. The UNICODE flag is for dealing with Unicode strings, which is what you need here. You shouldn't be using both at the same time! unicode_pattern=re.compile(self.pattern,re.UNICODE|re.LOCALE) for word_object in unicode_pattern.finditer(text): if not self.dict.spell(word_object.group()): print word_object.group() self.setFormat(word_object.start(), word_object.end() - word_object.start(), format) But whenever I pass unicode values into my QTextEdit the re.finditer() does not seem to collect it. When I pass I am a नेपाली into the QTextEdit. The output is like this: I I I a I am I am I am a I am a I am a I am a I am a I am a I am a I am a It is completely ignoring the unicode. What might be the issue. I am new to PyQt and regex. Im using Python 2.7 and PyQt4. There's an alternative regex implementation at: http://pypi.python.org/pypi/regex It's a drop-in replacement for the re module, but with a lot of additions, including better handling of Unicode. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
On 06/23/2013 12:05 PM, Ian Kelly wrote: On Sun, Jun 23, 2013 at 12:46 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: All is not lost, there are ways to make your classes cooperative. The trick is to have your classes' __init__ methods ignore keyword arguments they don't know what to do with. object used to do the same thing, but it no longer does, so you need to add an extra class just before object to swallow any args before they read object. class Blocker(object): def __init__(self, **kwargs): # Block kwargs from reaching object super(Blocker, self).__init__() I don't like the idea of doing this with a cooperative __init__ method. If any keyword arguments were passed that weren't consumed, that is probably a bug, and this just swallows the exception instead of reporting it. +1 Z Of course, if you're doing cooperative inheritance with some other method that doesn't exist on object, then this technique is necessary to prevent the topmost class from trying to call that method on object and erroring out. But in that case the Blocker wouldn't call super since it is acting as the base class. -- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this PEP-able? fwhile
On 26.06.2013 16:28, William Ray Wing wrote: On Jun 26, 2013, at 7:49 AM, Fábio Santos fabiosantos...@gmail.com mailto:fabiosantos...@gmail.com wrote: On 26 Jun 2013 11:45, jim...@aol.com mailto:jim...@aol.com wrote: On Tuesday, June 25, 2013 9:30:54 PM UTC+5:30, Ian wrote: In my experience the sorts of people who preach one exit point are also all about defining preconditions and postconditions and proving that the postconditions follow from the preconditions. I think that the two are linked, because the one exit point rule makes those sorts of proofs simpler. Ah! utopia! For every one who knows about pre/post/invariant conditions, there are 10 who follow goto-statement-is-harmful like a religious edict. I just checked and MISRA-C 2012 now allows gotos in specific, limited circumstances. I think it was the MISRA-C 1998 standard that caused all this trouble. So if MISRA now allows goto, why not Python :) What is the matter? Just use the goto module... Wondered when that would be mentioned. Personally, I've never found that much use for GoTo, but as old timers know, that same module adds the Come_From entry point, which is priceless. ;-) Bill Actually, jumping to any place a program (I know it from QBasic :) ) is some kind of voodoo. At first it seems that any function calling itself or calling another function from another function solves the goto puzzle - called OO programming, objects in space and inheritance? But at 2nd glimpse, jumping in any place of code (function) or routine, at a given place precisely - and to avoid any checks and unrelated code which might occur on a regular function call and without the need to provide additional arguments - that's kinda cool (if variables are in scope by the target statements :) ) That's somehow how I remember it. But I guess if everything should run as in a factory, one entrance, one component, one result and independently from each other (isolated) and on many cores and such, a goto without argument passing or state variables might just end up in a big mess. What do you think? -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
On 06/23/2013 11:50 AM, Steven D'Aprano wrote: On Sun, 23 Jun 2013 12:04:35 -0600, Ian Kelly wrote: On Sun, Jun 23, 2013 at 11:36 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 23 Jun 2013 11:18:41 -0600, Ian Kelly wrote: Incidentally, although super() is useful, it's not perfect, and this is one of my grievances with it: that a user can, based upon the name, draw an inaccurate assumption about what it does without reading or fully understanding the documentation on it, which might then result in misusing it. Wait a second... are you saying that the Python developers created an advanced language feature relating to multiple inheritance, one of the most complex OOP concepts around, so difficult that most other languages simply prohibit it completely, and it wasn't instantly and correctly intuited by every single programmer based only on the name? Oh my stars, somebody call Ranting Rick, he needs to write a PyWart post to expose this scandal!!! Mostly I'm saying that super() is badly named. What else would you call a function that does lookups on the current object's superclasses? Well, I would call it super(). Trouble is, that is not all that super() does. Going back to Ian's example: On 06/23/2013 10:08 AM, Ian Kelly wrote: class Base1(object): def __init__(self, foo, **kwargs): super(Base1, self).__init__(**kwargs) class Base2(object): def __init__(self, bar, **kwargs): super(Base2, self).__init__(**kwargs) class Derived(Base1, Base2): def __init__(self, **kwargs): super(Derived, self).__init__(**kwargs) Notice how Base1 calls super(), but depending on circumstances, it could by Base2 that super() calls. Surely you are not suggesting that Base2 is therefore an ancestor of Base1? It's too late to change the name now, but pretending there is no good and valid reason for confusion doesn't help. -- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Need help removing trailing zeros
Hello, i'm making a calculator and I want to be able to use decimals but I don't like it when it comes out as ex.12.0 when it should be 12. I tried using .rstrip(0.rstrip(.) but that never seemed to work. If anyone has a solution please let me know, all help is greatly appreciated. Code: def Main(): print( Welcome to the Calculator! What would you like to do?) print() print(1) Basic Operations) user_input = input(Enter the number corresponding with your choice: ) if user_input == 1: BasicOperations() def BasicOperations(): def Add(): A = float(input(Enter the first number you want to add: )) B = float(input(Enter the second number you want to add: )) Answer = A+B print(The sum of, A, and, B, is: , Answer) print() Main() def Sub(): A = float(input(Enter the first number you want to subtract: )) B = float(input(Enter the second number you want to subtract: )) Answer = A-B print(The difference between, A, and, B, is: , Answer) print() Main() def Mul(): A = float(input(Enter the first number you want to multiply: )) B = float(input(Enter the second number you want to multiply: )) Answer = A*B print(The product of, A, and, B, is: , Answer) print() Main() def Div(): A = float(input(Enter the first number you want to divide: )) B = float(input(Enter the second number you want to divide: )) Answer = A/B print(The quotient of, A, and, B, is: , Answer) print() Main() print(You have selected Basic Operations.) print(1) Addition) print(2) Subtraction) print(3) Multiplication) print(4) Division) print() choice = input(Select the number corresponding with your choice: ) if choice == 1: Add() elif choice == 2: Sub() elif choice == 3: Mul() elif choice == 4: Div() Main() -- http://mail.python.org/mailman/listinfo/python-list
Re: Limit Lines of Output
On 26 June 2013 17:46, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 26 Jun 2013 16:24:56 +0100, Joshua Landau wrote: On 25 June 2013 22:48, Gene Heskett ghesk...@wdtv.com wrote: On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: I did not. Unless there are two people called Joshua Landau with email address joshua.landau...@gmail.com, I'm afraid that you did. Ah, but as rusi has understood, I did not. (Although I did not may itself be opining, that was not the quoted text.) Hey, sometimes I just like being cryptic. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help removing trailing zeros
On 26 June 2013 23:02, bandcam...@gmail.com wrote: Hello, i'm making a calculator and I want to be able to use decimals but I don't like it when it comes out as ex.12.0 when it should be 12. I tried using .rstrip(0.rstrip(.) but that never seemed to work. If anyone has a solution please let me know, all help is greatly appreciated. Code: LOTS 'O CODE Was that really necessary? All you needed to give use was print(1.0); why post so much? Either: {:g}.format(1.0) or, if you hate scientific notation: {:f}.format(1.0).rstrip(.0) -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help removing trailing zeros
Sorry about that... And thanks for your help, but I don't quite understand. Would that make it off your example print({:g}.format(1.0))? -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help removing trailing zeros
On 26 June 2013 23:21, PyNoob bandcam...@gmail.com wrote: Sorry about that... And thanks for your help, but I don't quite understand. That's fine, but... Would that make it off your example print({:g}.format(1.0))? I don't understand this sentence. But, hey, I forgot to check what level you were working at -- there's little point running ahead of what you know. Did you try: print({:g}.format(1.0)) ? It works for me. So, yes, that's what you want. So instead of: print(The quotient of, A, and, B, is: , Answer) you want print(The quotient of, A, and, B, is: , {:g}.format(Answer)) See how I just used {:g}.format as some kind of magic-fixing-power? Well, why does it work? [See http://docs.python.org/3/library/stdtypes.html#str.format and the sub-links for a more full explanation] Run each of these in an interpreter: {} {} {} {} {}.format(This, is, a, formatted, string!) It is really useful: I have {} cows and {} sheep.format(number_of_cows, number_of_sheep) It gives me back a formatted {}, which I can print.format(type(.format()).__name__) I can also give things indexes: {3} {2} {1} {0}.format(Print, in, reverse, order) I can also give things names: {egg} {ham} {flies}.format(egg=Are, ham=you, flies=there?) It's not just {:!10}.format(that) It lets me choose how I want things to be printed: {0:@^6}, {0:~10}, {0:£8}.format(Hi) And for numbers: {0:e}, {0:.10%}, {0:#.1f}.format(123.456) So you just want the best formatter; see [http://docs.python.org/3/library/string.html#format-specification-mini-language] Your best choice is {:g} which just means general format. Note that you can also write your prints as so: print(The quotient of {} and {} is: {:g}.format(A, B, Answer)) Whether you prefer it is your choice. -- In regards to .rstrip: It will only work on strings; so you need to convert like so: str(1.0).rstrip(0).rstrip(.) And note that: 1) My .rstrip(0.) was wrong and foolish (try str(10).rstrip(0.)) 2) This needs the string to be reliably formatted in this style: {:#f} *and* requires it to be a float. So really, you'd need: {:#f}.format(float(number)).rstrip(0).rstrip(.) Which is ugly, but I guess it works. -- http://mail.python.org/mailman/listinfo/python-list
SQL code generation from table-free boolean queries?
Given string input such as: foo=5 AND a=6 AND date=now OR date='2013/6' AND bar='hello' I am going to implement: - boolean understanding (which operator takes precendence) - spliting off of attributes into my function which computes their table in the SQL database - piece everything together into an SQL query However, it came to me that this is probably a very generic thing; and there might be a library for it. If that's so, can you recommend it? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: class factory question
On 26 June 2013 16:40, Peter Otten __pete...@web.de wrote: Joshua Landau wrote: I would say if a dict isn't good, there are still some cases where you might not want to use globals. I _might_ do: # Make a module module_for_little_classes = ModuleType(module_for_little_classes, All the things) module_for_little_classes.__dict__.update(little_classes) Hm, from within module_for_little_classes that is globals(). To illustrate: import __main__ as main globals() is main.__dict__ True Yes, that's true - but the point wasn't not to use globals the function, but not to use *this* global scope. Also, I'd spell module.__dict__ vars(module). Again, good catch. Definitely that. That said I agree that it's a good idea to use a dedicated module (not necessarily created on the fly) for those dynamically generated classes. -- http://mail.python.org/mailman/listinfo/python-list
Re: SQL code generation from table-free boolean queries?
On 2013-06-26 16:17, Foo Stack wrote: Given string input such as: foo=5 AND a=6 AND date=now OR date='2013/6' AND bar='hello' I am going to implement: - boolean understanding (which operator takes precendence) - spliting off of attributes into my function which computes their table in the SQL database - piece everything together into an SQL query However, it came to me that this is probably a very generic thing; and there might be a library for it. It sounds like you might want to use pyparsing and start with something akin to this[1] -tkc [1] http://pyparsing.wikispaces.com/file/view/simpleSQL.py -- http://mail.python.org/mailman/listinfo/python-list
Re: class factory question
On 26 Jun 2013 14:14, Tim jtim.arn...@gmail.com wrote: I am extending a parser and need to create many classes that are all subclassed from the same object (defined in an external library). When my module is loaded I need all the classes to be created with a particular name but the behavior is all the same. Currently I have a bunch of lines like this: class Vspace(Base.Command): pass class Boldpath(Base.Command): pass There are a bunch of lines like that. Is there a better way? Something like newclasses = ['Vspace', 'Boldpath', ... ] for name in newclasses: tmp = type(name, (Base.Command,) {}) tmp.__name__ = name Is there a more pythonic way? thanks, --Tim I would say The Most Pythonic Way is to use the class declarations as you are doing now. Explicit is better than implicit, or so the zen says. It will be better for tools as well. I'd like to see code completion work on dynamically created classes like that (unless you use __all__ to list them.). And, are you really looking for classes here? If you just want to create different names with different identities, you could consider using plain old strings or object() to do that. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
On Wed, 26 Jun 2013 13:14:44 -0700, Ethan Furman wrote: On 06/23/2013 11:50 AM, Steven D'Aprano wrote: What else would you call a function that does lookups on the current object's superclasses? Well, I would call it super(). Trouble is, that is not all that super() does. Going back to Ian's example: On 06/23/2013 10:08 AM, Ian Kelly wrote: class Base1(object): def __init__(self, foo, **kwargs): super(Base1, self).__init__(**kwargs) class Base2(object): def __init__(self, bar, **kwargs): super(Base2, self).__init__(**kwargs) class Derived(Base1, Base2): def __init__(self, **kwargs): super(Derived, self).__init__(**kwargs) Notice how Base1 calls super(), but depending on circumstances, it could by Base2 that super() calls. Surely you are not suggesting that Base2 is therefore an ancestor of Base1? No. But the current object is not Base1, but an instance of Derived, and Base2 *is* an ancestor of Derived. Perhaps if I had said self instead of current object, you wouldn't have made this error. If so, I apologise for confusing you. When your inheritance chain begins from an instance of Base1, Base2 methods will never be called. It is only when the chain begins from Derived that Base2 may be called, which is exactly as it should be. It's too late to change the name now, but pretending there is no good and valid reason for confusion doesn't help. The confusion is not with the name, or what super does, but with inheritance itself. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Limit Lines of Output
On Wed, 26 Jun 2013 10:09:13 -0700, rusi wrote: On Wednesday, June 26, 2013 8:54:56 PM UTC+5:30, Joshua Landau wrote: On 25 June 2013 22:48, Gene Heskett wrote: On Tuesday 25 June 2013 17:47:22 Joshua Landau did opine: I did not. I guess Joshua is saying that saying ≠ opining But it is. From WordNet: opine v 1: express one's opinion openly and without fear or hesitation; John spoke up at the meeting [syn: opine, speak up, speak out, animadvert, sound off] Admittedly we cannot tell what Joshua's mental state was at the time he responded to Bryan, he may have been absolutely terrified for all we know, but there's no sign of this fear, and no reason to think that he hesitated, given that his response came through a mere nine minutes after Bryan's comment. Or if you prefer the Collaborative International Dictionary of English: Opine \O*pine\, v. t. i. [imp. p. p. Opined; p. pr. vb. n. Opining.] [L. opinari, p. p. opinatus; akin to opinus (in comp.) thinking, and perh. to E. apt: cf. F. opiner.] To have an opinion; to judge; to think; to suppose. --South. [1913 Webster] [Or is he opining?] That's just his opinion, man. *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
On Wed, Jun 26, 2013 at 5:54 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: No. But the current object is not Base1, but an instance of Derived, and Base2 *is* an ancestor of Derived. Perhaps if I had said self instead of current object, you wouldn't have made this error. If so, I apologise for confusing you. If I am reading a class definition and see the code super().__init__(), and I am not familiar with super() and do not bother to go look it up in the docs because it looks obvious (or perhaps I have read a tutorial that simply mentions that super() is used to call methods from a superclass and elides over the details) -- my assumption is not going to be that super() is looking into superclasses relative to the class of self, but more simply that super() is looking into superclasses relative to the class that I'm currently reading. Why? Because that's the way that super works in every other language I know of that has it. Java: super looks depth-first from the contextual class (no multiple inheritance allowed) Ruby: super looks depth-first from the contextual class (no multiple inheritance allowed) Objective-C: super looks depth-first from the contextual class (no multiple inheritance allowed) Perl 5: by default, super looks depth-first from the contextual class (multiple inheritance IS allowed; the C3 linearization (MRO) CAN be used, but it must first be explicitly enabled with a pragma directive) Now if you're coming from Java, Ruby, or Objective-C and reading a Python super() statement, then hopefully you will stop and think, Hey, wait a minute. [Other language] doesn't have multiple inheritance and Python does, so how does super() work here? More likely though you're not even thinking about multiple inheritance when you read that statement, and you just assume that it works exactly like the super keyword that you're used to, and you move on. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the semantics meaning of 'object'?
On 06/26/2013 04:54 PM, Steven D'Aprano wrote: On Wed, 26 Jun 2013 13:14:44 -0700, Ethan Furman wrote: On 06/23/2013 11:50 AM, Steven D'Aprano wrote: What else would you call a function that does lookups on the current object's superclasses? Well, I would call it super(). Trouble is, that is not all that super() does. Going back to Ian's example: On 06/23/2013 10:08 AM, Ian Kelly wrote: class Base1(object): def __init__(self, foo, **kwargs): super(Base1, self).__init__(**kwargs) class Base2(object): def __init__(self, bar, **kwargs): super(Base2, self).__init__(**kwargs) class Derived(Base1, Base2): def __init__(self, **kwargs): super(Derived, self).__init__(**kwargs) Notice how Base1 calls super(), but depending on circumstances, it could by Base2 that super() calls. Surely you are not suggesting that Base2 is therefore an ancestor of Base1? No. But the current object is not Base1, but an instance of Derived, and Base2 *is* an ancestor of Derived. Perhaps if I had said self instead of current object, you wouldn't have made this error. If so, I apologise for confusing you. No apology necessary. I understand both inheritance and super fairly well, and you did not confuse me. When your inheritance chain begins from an instance of Base1, Base2 methods will never be called. It is only when the chain begins from Derived that Base2 may be called, which is exactly as it should be. Absolutely. That doesn't change the fact that when writing Base1 you are still using the word 'super', and hopefully remembering that even though it's named 'super' it may in fact call an object that is sideways from where you're at now and have absolutely no relation to Base1's ancestors. It's too late to change the name now, but pretending there is no good and valid reason for confusion doesn't help. The confusion is not with the name, or what super does, but with inheritance itself. Good names are important because a good name can help alleviate confusion. A bad name can exacerbate it. Given the terminology of superclasses and subclasses, naming a function 'super' that can in fact call another class that is in no way the superclass of the class in which it is written, can easily cause confusion. -- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help removing trailing zeros
I get it now! Thank you so much for your help, I really appreciate it. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: re.finditer() skips unicode into selection
Thanks MRAB, your suggestion worked. But then it brought an error 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128) I corrected this by encoding it to 'utf-8'. The code looks like this now. pattern = ur'(?u)\w+' def __init__(self, *args): QSyntaxHighlighter.__init__(self, *args) self.dict = None def setDict(self, dict): self.dict = dict def highlightBlock(self, text): if not self.dict: return text = unicode(text) format = QTextCharFormat() format.setUnderlineColor(Qt.red) format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline) unicode_pattern=re.compile(self.pattern,re.UNICODE) for word_object in unicode_pattern.finditer(text): if not self.dict.spell(word_object.group().encode('utf-8')): print word_object.group().encode('utf-8') self.setFormat(word_object.start(), word_object.end() - word_object.start(), format) The problem now is that all the vowels are separated from the root word, such that if you type मेरो, the म and े are printed separately. (the े appears as a box instead). What am I doing wrong? Like this. मेरो नाम रुपा हो। -- http://mail.python.org/mailman/listinfo/python-list
Re: re.finditer() skips unicode into selection
[IMG]http://i41.tinypic.com/35002rr.png[/IMG] Heres a screenshot http://i41.tinypic.com/35002rr.png -- http://mail.python.org/mailman/listinfo/python-list
FACTS: WHY THE PYTHON LANGUAGE FAILS.
= MESSAGE FROM COMPUTER GEEK. = THRINAXODON HAS RECENTLY RECEIVED THIS MESSAGE FROM THE PYTHON FOUNDER: Oh my God! It's hard to program with, it`s troubling for so many people! I call for the cancellation of the Python programming language. THRINAXODON: Wow! I had much trouble, myself. In fact; the makers of the Python language watch every move o, it, therefore violating privacy. FOUNDER: It`s weird...I have 5,000 pieces of info. on every person that uses it. That`s the real reason... THRINAXODON: I used it! FOUNDER: It`s really hard to use. It requires 20 books just to know how to code with it. THRINAXODON: Time to announce the cancellation at comp.lang.python! === THRINAXODON IS NOW ON TWITTER. -- http://mail.python.org/mailman/listinfo/python-list
Re: re.finditer() skips unicode into selection
Thanks MRAB your alternative regex implementation worked flawlessly. It works now. -- http://mail.python.org/mailman/listinfo/python-list
Re: FACTS: WHY THE PYTHON LANGUAGE FAILS.
Thrinaxodon biolo...@yahoo.com writes: [… strange fictitious dialogue …] THRINAXODON IS NOW ON TWITTER. Thrinaxodon should not bother to post such hostility here again. -- \ “I don't want to live peacefully with difficult realities, and | `\ I see no virtue in savoring excuses for avoiding a search for | _o__)real answers.” —Paul Z. Myers, 2009-09-12 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
[issue18303] json.dumps() claims numpy.ndarray and numpy.bool_ are not serializable
Ethan Furman added the comment: For the curious, here are all the tracebacks: -- json.dumps(a) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python3.3/json/__init__.py, line 236, in dumps return _default_encoder.encode(obj) File /usr/lib/python3.3/json/encoder.py, line 191, in encode chunks = self.iterencode(o, _one_shot=True) File /usr/lib/python3.3/json/encoder.py, line 249, in iterencode return _iterencode(o, 0) File /usr/lib/python3.3/json/encoder.py, line 173, in default raise TypeError(repr(o) + is not JSON serializable) TypeError: array([ True, True, True, True, False, False], dtype=bool) is not JSON serializable -- json.dumps(a[0]) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python3.3/json/__init__.py, line 236, in dumps return _default_encoder.encode(obj) File /usr/lib/python3.3/json/encoder.py, line 191, in encode chunks = self.iterencode(o, _one_shot=True) File /usr/lib/python3.3/json/encoder.py, line 249, in iterencode return _iterencode(o, 0) File /usr/lib/python3.3/json/encoder.py, line 173, in default raise TypeError(repr(o) + is not JSON serializable) TypeError: True is not JSON serializable While the repr says 'True', the type is class 'numpy.bool_'. and the success: -- json.dumps(a.tolist()) #this works! '[true, true, true, true, false, false]' Summary === No bug here, defined behavior. Raising the issue with NumPy won't help as this is not a bug... although perhaps they have a json handler already written somewhere? At any rate, yes, said handler would have to be specified as the 'default' parameter. -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18303 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18305] [patch] Fast sum() for non-numbers
New submission from Sergey: Problem === Code: sum([[1,2,3]]*100, []) takes forever to complete. Suggestion == Patch sum() function so that it did not created 100 copies of result, but created just one. Attached patch does that. Before patch: $ ./python -mtimeit --setup=x=[[1,2,3]]*1 sum(x,[]) 10 loops, best of 3: 915 msec per loop After patch: $ ./python -mtimeit --setup=x=[[1,2,3]]*1 sum(x,[]) 1000 loops, best of 3: 469 usec per loop 20% boost! :) Details === Built-in sum function could look like this: def sum(seq, start = 0): for item in seq: start += item return start But that would be bad, becaust in cases like: empty = [] result = sum(list_of_lists, empty) content of empty would be modified. So instead it looks like this: def sum(seq, start = 0): for item in seq: start = start + item return start it creates a copy of the entire partial result on EVERY start + item. While instead it could look like this: def sum(seq, start = 0): start = start + seq[0:1] for item in seq[1:]: start += item return start create just ONE copy, and use it. That's what attached patch is doing. An alternative is something like this: def sum(seq, start = 0): start = copy.copy(start) for item in seq: start += item return start But I'm not sure how to make a copy of arbitrary object yet. -- components: Interpreter Core files: fastsum.patch keywords: patch messages: 191896 nosy: Sergey priority: normal severity: normal status: open title: [patch] Fast sum() for non-numbers type: performance versions: Python 2.7 Added file: http://bugs.python.org/file30705/fastsum.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18305 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18298] pythonw.exe fails with redirected stderr
anatoly techtonik added the comment: I am not using pythonw.exe, it is the option users prefer to run the program. pythonw.exe is a binary, how do you propose to patch that? Or is it translated to .exe with RPython? Can you be more specific what shell does not work correctly, what exactly does not work correctly, and what is the backward-incompatible behaviour that you want to avoid? pythonw.exe is meant to suppresses the terminal window on startup (console window to be exact), but not to kill vital streams for an application. I posted links Spyder IDE source to show how it should be done. -- resolution: wont fix - status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18298 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18298] pythonw.exe fails with redirected stderr
Amaury Forgeot d'Arc added the comment: RPython... let's be serious. The code of pythonw.exe is very simple, see PC/WinMain.c. No, pythonw.exe is not meant to suppresses the terminal window on startup. This is only a consequence of being a windows application. There is a lot of documentation about this, for example: http://comsci.liu.edu/~murali/win32gui/Win32Apps.htm - python.exe is a regular console application, with a main() function. - pythonw.exe is a gui application, with a WinMain() function; as a consequence, stdout/stderr won't work properly. Again, it's a won't fix for 2.7, unless someone comes with a patch. But this has already been tried, and be careful, different versions of the msvcrt differ in behavior here. -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18298 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18306] os.stat gives exception for Windows junctions in v3.3
New submission from John Jefferies: If os.stat is executed on a Windows junction with Python 3.3 I see an exception: import os os.stat('C:\Windows\System32\config\systemprofile\SendTo') Traceback (most recent call last): File stdin, line 1, in module FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Windows\\System32\\config\\systemprofile\\SendTo' whereas with Python 3.2 it works without error: import os os.stat('C:\Windows\System32\config\systemprofile\SendTo') nt.stat_result(st_mode=16895, st_ino=281474977136630, st_dev=0, st_nlink=1, st_uid=0, st_gid=0, st_size=0, st_atime=1295885671, st_mtime=1295885671, st_ctime=1295885671) FTR. Some background: It's a pity that Python doesn't just treat Windows junctions as a normal soft link. But given that islink() returns False for a junction, I was able to work around that in Python 3.2 like this: if os.path.islink(fullname) or \ os.stat(fullname)[stat.ST_INO] != os.lstat(fullname)[stat.ST_INO]: # If it's not a link, it's probably a junction... Many thanks for looking. John -- components: Library (Lib) messages: 191899 nosy: John.Jefferies priority: normal severity: normal status: open title: os.stat gives exception for Windows junctions in v3.3 type: behavior versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18306 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18295] Possible integer overflow in PyCode_New()
Martin v. Löwis added the comment: I don't think they are actually the *same* issue. For the limitations wrt. code objects (maximum size of byte code, maximum number of local variables, maximum number of parameters, etc.), I recommend the following thorough procedure: 1. document in a single text file all the limitations 2. check for each one whether an int is sufficient to represent them at runtime. 3. if yes: leave all structure definitions as-is. Local variables might be changed to size_t where this simplifies the code. Otherwise, Py_SAFE_DOWNCAST should be used where the actual value ought to be valid already. Runtime errors where a value may come from the outside that might be out of range. 4. if not: widen the structures to Py_ssize_t. -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18295 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue706263] print in pythonw raises silent exception when no console available
anatoly techtonik added the comment: This is still an issue for Python 2 users. Most important that pythonw.exe has a magic ability to fail silently leaving users with no means to create valid bug reports (the reason why StackOverflow questions are downvoted and erased). http://bugs.ascend4.org/print_bug_page.php?bug_id=471 stream https://code.google.com/p/spyderlib/issues/detail?id=1260 The argument in msg15198 is somewhat misleading. If pythonw.exe fails because of print statement or because other issue, there is no way to report that. Anyway, this reminds me very much of mod_wsgi, with only problem that Python developers don't receive as much feedback as Graham to make the change: http://blog.dscpl.com.au/2009/04/wsgi-and-printing-to-standard-output.html -- nosy: +techtonik title: print raises exception when no console available - print in pythonw raises silent exception when no console available ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue706263 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5845] rlcompleter should be enabled automatically
Changes by anatoly techtonik techto...@gmail.com: -- nosy: +techtonik ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue706263] print in pythonw raises silent exception when no console available
Christian Heimes added the comment: I recommend against changing the code so late in the Python 2.7 release cycle. A change in behavior is too confusing. And it's not a bug but a design decision, too. Over five years ago I implement parts of the IO interaction with the operating system for Python 3.0. I deliberately did NOT port modifications to 2.6. If you want to get Python 3.x style print() behavior in Python 2.7 you can have it already: from __future__ import print_function import sys if sys.executable.endswith(pythonw.exe): sys.stdout = sys.stdout = None print(can handle sys.stdout = None just fine.) -- nosy: +christian.heimes resolution: - wont fix stage: - committed/rejected status: open - pending type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue706263 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18306] os.stat gives exception for Windows junctions in v3.3
Christian Heimes added the comment: Let's have a look -- assignee: - christian.heimes keywords: +3.3regression nosy: +christian.heimes stage: - test needed versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18306 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18305] [patch] Fast sum() for non-numbers
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18305 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18306] os.stat gives exception for Windows junctions in v3.3
Christian Heimes added the comment: On my Windows box (Win 7) I'm getting an error with Python 3.2 and 3.3. It looks like I'm not allowed to enter the parent directory (Zugriff verweigert == Permission Denied): os.stat(r'C:\Windows\System32\config') Traceback (most recent call last): File stdin, line 1, in module WindowsError: [Error 5] Zugriff verweigert: 'C:\\Windows\\System32\\config' In order to reproduce your problem anyway I have created a directory, a junction point and a symlink (as admin): mkdir testdir mklink /j testjunktion testdir mklink /d testlinkk testdir Neither os.stat() nor os.lstat() have failed with an exception. There must be something different going on on your system. By the way junction points are soft links but not symbolic links. They are implemented as a different kind of NTFS reparsing points. Python should not treat a junction point as a link but have yet another check for it. os.lstat(r'c:\users\heimes\testdir') nt.stat_result(st_mode=16895, st_ino=58265320179130300, st_dev=3366304641, st_nlink=1, st_uid=0, st_gid=0, st_size=0, st_atime=1372247959, st_mtime=1372247959, st_ctime=1372247959) os.lstat(r'c:\users\heimes\testjunction') nt.stat_result(st_mode=16895, st_ino=4785074604141776, st_dev=3366304641, st_nlink=1, st_uid=0, st_gid=0, st_size=0, st_atime=1372247983, st_mtime=1372247983, st_ctime=1372247983) os.lstat(r'c:\users\heimes\testlink') nt.stat_result(st_mode=41471, st_ino=12384898975270541, st_dev=3366304641, st_nlink=1, st_uid=0, st_gid=0, st_size=0, st_atime=1372249830, st_mtime=1372249830, st_ctime=1372249830) PS: You should use raw strings on Windows or escape the backslashes. -- assignee: christian.heimes - nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18306 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18306] os.stat gives exception for Windows junctions in v3.3
Christian Heimes added the comment: There is much confusing about junction point on the internet. Some sites like Wikipedia claim that a junction point is a kind of soft link. Other sites refer to junction points as directory hard links. IMO directory hard links is wrong. Contrary to file hard links a junction point doesn't keep the target directory alive when the target is removed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18306 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18289] python.org Interactive interpreter linked with libedit can segfault on future OS X
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18289 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18306] os.stat gives exception for Windows junctions in v3.3
John Jefferies added the comment: On 26/06/2013 13:38, Christian Heimes wrote: Christian Heimes added the comment: On my Windows box (Win 7) I'm getting an error with Python 3.2 and 3.3. It looks like I'm not allowed to enter the parent directory (Zugriff verweigert == Permission Denied): Ah. You need to be an administrator to look at the system directories? [I'm also on Win7]. Neither os.stat() nor os.lstat() have failed with an exception. There must be something different going on on your system. I didn't look closely enough; only the junctions in system folders are failing for me with an exception. The junctions in my user directory are not. I do hope I haven't wasted too much of your time in not describing the problem correctly. By the way junction points are soft links but not symbolic links. They are implemented as a different kind of NTFS reparsing points. Python should not treat a junction point as a link but have yet another check for it. I realise there are differences between junctions and symlinks at the ntfs level, but the only things that seem relevant to the application are that junctions are limited to directories on a local volume. So I consider junctions to be a subset of symlinks. Regardless, any reliable indication that a directory is a junction would be useful, and the hack I've been using thus far appeared to work for all the junctions on my system. PS: You should use raw strings on Windows or escape the backslashes. Yes, I'm ashamed, I did know that but missed it from the example. Many thanks. John -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18306 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18307] Relative path in co_filename for zipped modules
New submission from Vitaly Murashev: Recently I found out that it not possible to debug python code if it is a part of zip-module. Python version being used is 3.3.0 Well known GUI debuggers like Eclipse+PyDev or PyCharm are unable to start debugging and give the following warning: --- pydev debugger: CRITICAL WARNING: This version of python seems to be incorrectly compiled (internal generated filenames are not absolute) pydev debugger: The debugger may still function, but it will work slower and may miss breakpoints. --- So I started my own investigation of this issue and results are the following. At first I took traditional python debugger 'pdb' to analyze how it behaves during debug of zipped module. 'pdb' showed me some backtaces and filename part for stack entries looks malformed. I expected something like 'full-path-to-zip-dir/my_zipped_module.zip/subdir/test_module.py' but realy it looks like 'full-path-to-current-dir/subdir/test_module.py' Source code in pdb.py and bdb.py (which one are a part of python stdlib) gave me the answer why it happens. The root cause are inside Bdb.format_stack_entry() + Bdb.canonic() Please take a look at the following line inside 'format_stack_entry' method: filename = self.canonic(frame.f_code.co_filename) For zipped module variable 'frame.f_code.co_filename' holds _relative_ file path started from the root of zip archive like 'subdir/test_module.py' And as relult Bdb.canonic() method gives what we have - 'full-path-to-current-dir/subdir/test_module.py' --- Looks like it is a bug in: - in python core subsystem which one is responsible for loading zipped modules - or in pdb debugger -- components: Interpreter Core, Library (Lib) messages: 191907 nosy: vmurashev priority: normal severity: normal status: open title: Relative path in co_filename for zipped modules type: behavior versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18307 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18308] checkRecvmsgAddress wrong in test_socket.py (AIX failures)
New submission from David Edelsohn: The recvmsg tests in test_socket.py check that the address returned by recvmsg matches the original address to which the socket was bound. For IPv6, sockaddr includes sin6_scope_id, in addition to the address and port. The test connects to host ::1, which is loopback, but is an under-specified address because the link scope is left ambiguous. The scope_id in the original bind call defaults to 0, which represents an ambiguous scoped address and allows the IPV6 protocol and implementation to choose the interface or site identifier. The recvmsg call returns the actual scope_id. The test incorrectly checks that the full sockaddr matches. sin6_scope_id may not match for IPv6 addresses. This generates bogus failures on AIX. (Microsoft has a good description about scope_id: http://msdn.microsoft.com/en-us/library/windows/desktop/ms739166%28v=vs.85%29.aspx) -- components: Tests messages: 191908 nosy: David.Edelsohn priority: normal severity: normal status: open title: checkRecvmsgAddress wrong in test_socket.py (AIX failures) type: behavior versions: Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18308 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18309] Make python slightly more relocatable
New submission from Mathias Fröhlich: Hi all, I want to move python a bit closer to be relocatable. One problem to solve is where python finds its modules. The usual lookup mechanism is to compile in a configure time determined prefix that is used as a last resort path if the paths are not set otherwise during application/interpreter startup. The most commonly known way to change the module path at startup time are probably the environment variables PYTHONPATH and PYTHONHOME. The python interpreter itself already tries to interpret argv[0] to get to this point, but it would be nice if an application embedded interpreter also finds its module path without providing this argv[0] directly to the python library. This should even work if being moved or being installed at a different path than the configure time prefix path. The proposal is to add an additional attempt to find the python modules just before we resort to the compiled in prefix by looking at the path to the python27.{so,dll}. Relative to this shared object python library file the python modules are searched in the usual way. If there are no python modules found relative to the python library file, the very last resort compiled in prefix is used as usual. For architectures where we cannot determine the path of the shared library file, nothing changes. I have attached a patch that tries to implement this. It should serve as a base for discussions. This change is tested on linux and behaves like expected. The windows code for this is copied over from an other project where I have this actively running. But this python code variant is not even compile tested on windows. thanks in advance Mathias -- components: Installation files: python-relative-path-lookup.diff keywords: patch messages: 191909 nosy: mathias priority: normal severity: normal status: open title: Make python slightly more relocatable versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file30706/python-relative-path-lookup.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18309 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11454] email.message import time
Roundup Robot added the comment: New changeset 520490c4c388 by R David Murray in branch 'default': #11454: Reduce email module load time, improve surrogate check efficiency. http://hg.python.org/cpython/rev/520490c4c388 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11454 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11454] email.message import time
R. David Murray added the comment: I've checked in the encode version of the method. I'm going to pass on doing the other inlines, given that the improvement isn't that large. I will, however, keep the issue in mind as I make other changes to the code, and there will be a general performance review phase when I get done with the API additions/bug fixing in the email6 project. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11454 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18307] Relative path in co_filename for zipped modules
Changes by Christian Heimes li...@cheimes.de: -- nosy: +brett.cannon, christian.heimes stage: - test needed versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18307 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18310] itertools.tee() can't accept keyword arguments
New submission from py.user: import itertools itertools.tee('x', n=2) Traceback (most recent call last): File stdin, line 1, in module TypeError: tee() takes no keyword arguments -- components: Library (Lib) messages: 191912 nosy: py.user priority: normal severity: normal status: open title: itertools.tee() can't accept keyword arguments type: behavior versions: Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18310 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18311] Typo in SSL documentation
New submission from mp: Under http://docs.python.org/3.4/library/ssl.html#ssl.SSLContext.set_npn_protocols avertise should be advertise. This is in documentation for both 3.4 and 3.3 -- assignee: docs@python components: Documentation messages: 191913 nosy: docs@python, pfista priority: normal severity: normal status: open title: Typo in SSL documentation versions: Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18311 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18242] IDLE should not be replacing warnings.formatwarning
Changes by Terry J. Reedy tjre...@udel.edu: -- assignee: - terry.reedy versions: +Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18242 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18311] Typo in SSL documentation
Roundup Robot added the comment: New changeset d7ae8a84f443 by R David Murray in branch '3.3': #18311: fix typo. http://hg.python.org/cpython/rev/d7ae8a84f443 New changeset 16fe29689f3f by R David Murray in branch 'default': Merge #18311: fix typo. http://hg.python.org/cpython/rev/16fe29689f3f -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18311 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18311] Typo in SSL documentation
R. David Murray added the comment: Fixed, thanks. -- nosy: +r.david.murray resolution: - fixed stage: - committed/rejected status: open - closed type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18311 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18310] itertools.tee() can't accept keyword arguments
Christian Heimes added the comment: A bunch builtin types and functions don't accept keyword args. kwargs make code slightly more complexity and a tiny bit slower. -- assignee: - rhettinger nosy: +christian.heimes, rhettinger priority: normal - low ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18310 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7936] sys.argv contains only scriptname
TonyP added the comment: I have v2.7, v3.2, and v3.3 installed on a Win7 64-bit machine and the exact same setup on a Win7 32-bit machine. The 32-bit works OK. The 64-bit machine had this argv problem, too! (I tried installing either Win32/Win64 version, no difference!) Adding %* fixed the argv problem, but I noticed there was one more. The wrong version was called. To sum it up, I had to change only the key HKEY_CLASSES_ROOT/py_auto_file/shell/open/command from: c:\Python32\Python32.exe %1 %* to: c:\Python33\Python33.exe %1 %* or to: c:\windows\py.exe %1 %* (for auto-detection, both worked) -- nosy: +tonypdmtr ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7936 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18081] test_logging failure in WarningsTest on buildbots
Terry J. Reedy added the comment: I should have changed the Versions sooner, as soon as it became obvious that this was not just a 3.4 issue. The 'temporary' 3.4-only patch breaks forward merging of a better patch. I will back it out just before I commit a 3.3 patch to both eliminate the .formatwarning replacement (#18242) and move the .showwarning replacement (part of Victor's patch). If we ever add tests of PyShell.main and run.main (which we should), the problem of this issue will recur unless we make *sure* that the monkey patch moved inside those functions is reverted. Will try: finally: do that? I will leave this for a second patch. -- assignee: - terry.reedy versions: +Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18081 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9625] argparse: Problem with defaults for variable nargs when using choices
Changes by paul j3 ajipa...@gmail.com: -- nosy: +paul.j3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9625 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18306] os.stat gives exception for Windows junctions in v3.3
Changes by STINNER Victor victor.stin...@gmail.com: -- components: +Windows nosy: +haypo, tim.golden ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18306 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18305] [patch] Fast sum() for non-numbers
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18305 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17206] Py_XDECREF() expands its argument multiple times
Jeremy Kloth added the comment: Here is some additional analysis of recursive functions in the 'pythoncore' MSVC project: Ratio Release Debug Filename:Function Name StackStack --- 1.000 32 32_sre.asm:_validate_inner 1.159 352 408ast.asm:set_context 1.167 48 56compile.asm:stackdepth_walk 1.188 128 152memoryobject.asm:copy_rec 1.250 160 200ast.asm:num_stmts 1.308 104 136firstsets.asm:calcfirstset 1.312 128 168posixmodule.asm:win32_xstat_impl_w 1.400 40 56node.asm:freechildren 1.667 72 120memoryobject.asm:tolist_rec 1.750 32 56listnode.asm:list1node 1.750 32 56parsermodule.asm:parser_compare_nodes 1.750 32 56parsermodule.asm:validate_factor 1.750 32 56parsermodule.asm:validate_not_test 1.750 32 56rotatingtree.asm:RotatingTree_Enum 1.750 32 56typeobject.asm:solid_base 1.786 112 200bytearrayobject.asm:bytearray_setslice 1.900 80 152compile.asm:compiler_comprehension_generator 2.143 56 120pythonrun.asm:print_exception_recursive 2.167 48 104arraymodule.asm:array_ass_slice 2.250 32 72ast.asm:validate_slice 2.250 32 72getargs.asm:skipitem 2.250 32 72node.asm:sizeofchildren 2.250 32 72parsermodule.asm:validate_test 2.250 32 72setobject.asm:set_issuperset 2.278 144 328listobject.asm:list_ass_slice 2.417 96 232arraymodule.asm:array_ass_subscr 2.429 56 136longobject.asm:PyLong_AsLongLong 2.429 56 136parsermodule.asm:node2tuple 2.429 56 136typeobject.asm:mro_subclasses 2.500 80 200bytearrayobject.asm:bytearray_ass_subscript 2.600 40 104errors.asm:PyErr_GivenExceptionMatches 2.750 32 88import.asm:update_code_filenames 2.750 32 88setobject.asm:set_richcompare 2.750 32 88symtable.asm:symtable_visit_slice 2.750 32 88typeobject.asm:PyType_Modified 2.766 512 1416marshal.asm:r_object 3.125 64 200longobject.asm:long_rshift 3.250 32 104compile.asm:compiler_with 3.250 32 104setobject.asm:set_issubset 3.250 32 104typeobject.asm:assign_version_tag 3.750 32 120abstract.asm:abstract_issubclass 3.750 32 120typeobject.asm:PyType_Ready 3.833 48 184ast.asm:ast_for_expr 4.250 32 136compile.asm:compiler_visit_expr 4.250 32 136mathmodule.asm:factorial_partial_product 4.500 80 360genobject.asm:gen_throw 4.692 312 1464symtable.asm:symtable_visit_stmt 5.250 32 168_collectionsmodule.asm:deque_extend 5.250 32 168_collectionsmodule.asm:deque_extendleft 5.250 32 168ast.asm:alias_for_import_name 5.750 32 184typeobject.asm:merge_class_dict 6.250 32 200abstract.asm:PyObject_IsInstance 6.250 32 200abstract.asm:PyObject_IsSubclass 6.250 32 200ast.asm:validate_expr 6.500 48 312Python-ast.asm:obj2ast_slice 7.182 88 632parsermodule.asm:build_node_children 7.250 32 232errors.asm:PyErr_NormalizeException 9.167 48 440symtable.asm:symtable_visit_expr 10.250 32 328_json.asm:encoder_listencode_obj 10.344 256 2648Python-ast.asm:obj2ast_expr 15.955 176 2808Python-ast.asm:obj2ast_stmt 31.750 32 1016Python-ast.asm:ast2obj_expr -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17206 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com