Re: Looking for Remote Python Project
joy99 subhakolkata1...@gmail.com writes: But do you know whether it would be a paying one, I am looking to be a freelancer. You might find the Python Job Board useful URL:http://www.python.org/community/jobs/. -- \“Choose mnemonic identifiers. If you can't remember what | `\mnemonic means, you've got a problem.” —Larry Wall | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Use the Source Luke
On Sat, 29 Jan 2011 20:50:20 -0800, rusi wrote: On Jan 30, 9:21 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: I think this is a fairly accurate description of (one aspect of) the problem. If you dont see it as a problem how do you explain that google can search the World Wide Web better than we can search our individual hard disks? I fail to see any connection between the location that operating systems store files, and the ability of Google to index publicly available websites. http://en.wikipedia.org/wiki/Content-addressable_storage#Content- addressed_vs._Location-addressed Nope, sorry, doesn't help. Both local files on your hard drive, and most remote websites on the Internet, are location addressed. Google indexes the content, but they don't provide content-addresses. Indeed, they *can't* do so (except, possibly, for content they control such as Google Books), since they can't prevent content owners from modifying either the location address or the content. And as I've mentioned, there are desktop utilities that index content for Windows and Macintosh. In fact, Google themselves offer a desktop app that does just that: http://desktop.google.com/features.html -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple values for keyword argument
On Sat, 29 Jan 2011 10:39:49 -0800, patty wrote: I am glad you said this. I have been avoiding understanding this 'self', just accepting it :} For the time being, since my programs I am creating are for my own use, I think I will make my own names up, that are descriptive to me as the programmer, it's all going to be interpreted anyway. And the other email equating to C's argv, etc. - now I get it. That's a shame, because `self` is actually very simple once you understand the basic principles of object-oriented programming. What names would you choose? Unless you're writing descriptors, or using class methods, both of which should be considered advanced usage (highly advanced for descriptors, moderately so for class methods), it's not like every method needs a different descriptive first argument. In English, self, this, me or instance would be good names. What else would you use? The idea of method syntax is that you start with an instance of some class: mystring = hello world # an instance of the str class In procedural languages like C or Pascal, you would call a function and give the string as an argument. Python supports this programming model, and uses it for built-ins like len: len(mystring) = returns 11 Object oriented programming uses a different syntax. Instead of function(instance) as above, we take the instance argument outside the brackets. For example: mystring.upper() # instead of upper(mystring) = returns HELLO WORLD If there are any extra arguments needed, they go inside the brackets as normal. So far, this is just a change of syntax. It's like saying The cat of my brother's vs. my brother's cat -- the meaning is the same, but the syntax differs. The real advantages of object oriented programming and methods come elsewhere (e.g. encapsulation and inheritance). [Aside: when I was learning this, the hardest part I found was remembering which things were functions, and which were methods. I kept writing (wrongly!) things like: hello world.len() upper(hello world) Unfortunately there is no easy way to recognise what will be a function like len, and which are methods like upper. That will come with experience. Back to function/procedural syntax versus object oriented syntax... One difference, though, is when you write a method definition. Because the method you write starts off life as an ordinary function, you need to write it *as if* it were a function you call like len() above. Here's how you might write a method in a class: class MyClass: def method(self, extra): pass When you then call the method: instance = MyClass() instance.method(something extra) Python automatically changes the syntax for you, and passes two arguments to the function as if you did this: # pseudo-code set self = instance set extra = something extra extract method from MyClass call method(self, extra) We call the first argument something like self because it will ALWAYS be the instance itself. Unlike a regular function, which can have anything passed as the first argument, and therefore you should give it a descriptive name, the method's first argument is provided automatically for you and will always be the instance you started with. I hope this helps. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Use the Source Luke
On Sunday 30 January 2011 05:21, Steven D'Aprano wrote: If I *wanted* to index my files, I could do so, although in fairness I'm not aware of any Linux tools which do this -- I know of `locate`, which indexes file *names* but not content, and `grep`, which searches file content but doesn't index what it finds. You might find this page useful: http://www.wikinfo.org/index.php/Comparison_of_desktop_search_software David -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???
On Jan 28, 4:22 pm, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Fri, Jan 28, 2011 at 3:42 PM, bansi mail2ba...@gmail.com wrote: On Jan 28, 1:52 pm, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Fri, Jan 28, 2011 at 1:33 PM, bansi mail2ba...@gmail.com wrote: On Jan 28, 9:46 am, bansi mail2ba...@gmail.com wrote: On Jan 26, 8:31 pm, MRAB pyt...@mrabarnett.plus.com wrote: On 27/01/2011 00:57, bansi wrote: On Jan 26, 6:25 pm, Ethan Furmanet...@stoneleaf.us wrote: bansi wrote: First namelookupWrapper.py running under Python 2.6 accept arguments from stdin and uses csv reader object to read it i.e. r=csv.reader(sys.stdin) And then it has to pass csv reader object to another python script namelookup.py running under Python 2.7 because it uses pyodbc to connect to database and iterates thru reader object Ben Finney wrote: bansimail2ba...@gmail.com writes: Thanks Chris. Sorry for mis-communicating, the two python scripts are dependant in a way that namelookupWrapper.py needs to pass csv record object to another python script Why have you structured them that way, though? What constraint is keeping you from doing the work in a single process, where the CSV reader object can be shared? If thats not possible then please let me know how to do the workaround i didnt understood the import thing and not sure if it helps in my case The problem as you've described it so far is best solved by having a single process accessing the CSV reader object in memory. If that doesn't suit your use case, you'll need to explain why not. In other words, why can't you use Python 2.7 to accept input and generate a csv.reader? ~Ethan~- Hide quoted text - - Show quoted text - Ethan, The python script takes the input from Splunk (http://www.splunk.com/ base/Documentation/) which supports only Python 2.6 So the real constraint is Splunk supports only Python 2.6 . As you know Python 2.6 doesnt support or doesnt have pyodbc install for Windows 64 bit OS So i installed Python 2.7 and thereafter pyodbc install for Windows 64 bit OS for Python 2.7 Have you actually tried Splunk with Python 2.7? It might not work with versions which are earlier than Python 2.6, but that doesn't necessarily mean that it won't work with versions of Python 2 which are later than Python 2.6 (unless the documentation says that it must be Python 2.6).- Hide quoted text - - Show quoted text - Splunk's latest version 4.1.6 doesn't support Python 2.7 I tried the import trick but it didnt work because the real script which runs under Python 2.7 has import pyodbc so it results in following error c:\Splunk\etc\apps\search\binsplunk cmd python namelookupWrapper.py memberId memberName memberInput.csv Traceback (most recent call last): File namelookupWrapper.py, line 3, in module import namelookup File c:\Splunk\etc\apps\search\bin\namelookup.py, line 7, in module import pyodbc ImportError: DLL load failed: The specified module could not be found. Please let me know if i am missing something on import. If so please provide me with an example- Hide quoted text - - Show quoted text - Here are some more details from my earlier posting. Please click the below link http://answers.splunk.com/questions/11145/its-getting-mysterious-to-m... -- http://mail.python.org/mailman/listinfo/python-list Have you tried downloading the source for PyODBC and compiling it yourself? All you need to do is python setup.py install. My guess would be that it works just fine on 64-bit Python 2.6, they just never released a re-compiled version of it for that platform.- Hide quoted text - - Show quoted text - Thanks Benjamin. Please point me to the website from where i can download pyodbc for Windows 64 bit OS under Python 2.6 and installation instructions -- You don't download it for 64-bit Windows with Python 2.6. You download the source code from the website and make the Python 2.6, 64-bit Windows version yourself. Download the source zip file and extract it. Then, open up the command prompt and use the cd command to change directories to that source folder. For instance, if the source code has been extracted to C:\pyodbc-2.1.8\, you type in cd C:\pyodbc-2.1.8 and press enter. After that, you just run the build script which is already in there: C:\Python26\python26.exe setup.py install You'll need to have Visual C++ 2008 (not 2010) installed for this to work. You can get it for free fromhttp://www.microsoft.com/express/Downloads/if you don't already have it. http://mail.python.org/mailman/listinfo/python-list- Hide quoted text - - Show quoted text -- Hide
Re: Use the Source Luke
On Sat, 2011-01-29 at 21:17 -0800, Raymond Hettinger wrote: My thesis is that we can do even better than that by adding direct links from the docs to the relevant code with nice syntax highlighting. +1 - I think the source links are very useful (and thanks for pushing them). However I think the biggest changes that have probably happened with python itself are: (1) More users for whom this is their first language. (2) CS courses / training not teaching C (or pointer-based languages). (2) is especially important IMO - under half of the python developers I have regularly worked with would feel comfortable reading C - so for the other half reading C source code probably isn't going to help them understand exactly what's going on (although in the long run it might help them a lot) Tim Wintle -- http://mail.python.org/mailman/listinfo/python-list
Re: Use the Source Luke
On Jan 30, 2:53 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: In fact, Google themselves offer a desktop app that does just that: http://desktop.google.com/features.html Yes, but at the expense of your privacy! How much private information is being sent back to Google plex an used to flash more click ads at you? Well i guess we could say, google does spam us, but at least we are more likely to be *slightly* interested in the spam. -- http://mail.python.org/mailman/listinfo/python-list
Re: Use the Source Luke
On Jan 30, 6:19 pm, David Boddie da...@boddie.org.uk wrote: You might find this page useful: http://www.wikinfo.org/index.php/Comparison_of_desktop_search_software David Thanks for that link David I note particularly the disclaimer that it was removed from wikipedia [Like when your-unfavorite-TV-channel censors stuff you know it deserves a second look ;-) ] -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???
On Jan 30, 6:31 pm, bansi mail2ba...@gmail.com wrote: On Jan 28, 4:22 pm, Benjamin Kaplan benjamin.kap...@case.edu wrote: You'll need to have Visual C++ 2008 (not 2010) installed for this to work. You can get it for free fromhttp://www.microsoft.com/express/Downloads/if you don't already have it. Thanks Benjamin. Wondering why i need to Visual C++ 2008 . What it has to do with Python? Isn't it possible to implement your suggestion without installing Visual C++ 2008 . http://code.google.com/p/pyodbc/wiki/Building#Windows -- http://mail.python.org/mailman/listinfo/python-list
how to modify axis tick values exponential value location in matplotlib
Hi, I am plotting the graph for long values like(267838484) so that its printing the tick lables on axes as 2.6 , 2.8 and at the top its having a text like e07 something like this, I want to move the display location of this exponent (e07) as i am having trouble in having multiple y-axis as they are getting mixed in text. like (e07 is written on top of e08 of other axis) Can any one help me in getting this done? also i am having issue in getting tick lables of x-axis while plotting with pylab.plot_date. Regards Raja -- http://mail.python.org/mailman/listinfo/python-list
Style question: Nicknames for deeply nested objects
Hi all, Today I was thinking about a problem I often encounter. Say that I have (seems I often do!) a deeply nested object, by which I mean object within object with object, etc. For example: x = some.deeply.nested.object.method(some.other.deeply.nested.object.value) Well, that's extreme but I've worked with code approaching that level of nested-ness. Now, consider two scenarios: 1. You need to call this thing many times with different arguments, so you wind up with: x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) 2. You call it inside a loop: for item in some_iterable: x = some.deeply.nested.object.method(some.other.deeply.nested.object.value) For one thing, I find the long lines unattractive at best and error-prone at worst, especially if I also have some.other.deeply.nested.object.method that I might confuse with the first. To make it look better I might do this: _o = some.deeply.nested.object _o.method(_o.value) which is fine, I suppose. Then, putting on my company hat, I remembered that, from VBA, you could do this: with some.deeply.nested.object .method(.value) end with I like the structure of this, since the subordinate block can be indented, which makes it stand out. Also, it avoids temporary variables. So, I was thinking of how to get close to this in Python. I came up with two approaches: 1. _o = some.deeply.nested.object if 1: _o.method(_o.value) The if 1: forces me to indent the subordinate code, which sets it apart from the surrounding code. Note that I cannot just indent because I feel like it since Python is persnickety about indentation. 2. for _o in [some.deeply.nested.object]: _o.method(_o.value) The for... sets up the iterator and forces me to indent the subordinate code. As an aside, approach 1 generates less byte-code since approach 2 sets up loop machinery which you don't really need in this case. I have a couple of questions: 1. If you had to choose between approaches 1 and 2, which one would you go for, and why? 2. What other techniques have you used in such a situation? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question: Nicknames for deeply nested objects
On Jan 30, 11:51 am, Gerald Britton gerald.brit...@gmail.com wrote: [...] that I might confuse with the first. To make it look better I might do this: _o = some.deeply.nested.object _o.method(_o.value) which is fine, I suppose. It is very fine. And you supposed correctly! Then, putting on my company hat, I remembered that, from VBA, you could do this: with some.deeply.nested.object .method(.value) end with I like the structure of this, since the subordinate block can be indented, which makes it stand out. Also, it avoids temporary variables. Yes it is a good idea! Well forgetting the horrendous VBA syntax this is. I brought this up many moons back as a feature request: Local Blocks. Here is how a pythonic local block would look with this as localvar: localvar.do_something() So, I was thinking of how to get close to this in Python. I came up with two approaches: 1. _o = some.deeply.nested.object if 1: _o.method(_o.value) bad idea! 2. for _o in [some.deeply.nested.object]: _o.method(_o.value) even worse idea! I have a couple of questions: 1. If you had to choose between approaches 1 and 2, which one would you go for, and why? neither! Stick with the original. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to modify axis tick values exponential value location in matplotlib
it seems relevant to my issue. http://stackoverflow.com/questions/3677368/matplotlib-format-axis-offset-values-to-whole-numbers-or-specific-number On Sun, Jan 30, 2011 at 9:45 AM, Rajendra prasad Gottipati rajendra4li...@gmail.com wrote: Hi, I am plotting the graph for long values like(267838484) so that its printing the tick lables on axes as 2.6 , 2.8 and at the top its having a text like e07 something like this, I want to move the display location of this exponent (e07) as i am having trouble in having multiple y-axis as they are getting mixed in text. like (e07 is written on top of e08 of other axis) Can any one help me in getting this done? also i am having issue in getting tick lables of x-axis while plotting with pylab.plot_date. Regards Raja -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question: Nicknames for deeply nested objects
In article mailman.1469.1296409883.6505.python-l...@python.org, Gerald Britton gerald.brit...@gmail.com wrote: 1. You need to call this thing many times with different arguments, so you wind up with: x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) I would probably turn that into: object = some.deeply.nested.object object.method(object.value1) object.method(object.value2) object.method(object.value3) i.e. make the temporary variable have the exact same name as the last component of the deeply nested thing you're trying to refactor. If the scope of use is small and the meaning is obvious from context, sometimes I'll shorten the name, i.e. obj = some.deeply.nested.object or even o = some.deeply.nested.object but I tend to avoid doing that. I'd rather be a little more verbose in preference to being a little more cryptic. -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question: Nicknames for deeply nested objects
On 1/30/11 9:51 AM, Gerald Britton wrote: 1. If you had to choose between approaches 1 and 2, which one would you go for, and why? Neither. Ideally, I'd tweak the API around so the deeply nested structure isn't something I need to access regularly. But! If you can't do that, I'd do something like: --- start from contextlib import contextmanager class Item(object): pass deeply = Item() deeply.nested = Item() deeply.nested.thing = Item() @contextmanager def my(thing): yield thing with my(deeply.nested.thing) as o: o.hello = 1 print deeply.nested.thing.hello --- end That's a dummy context-manager which basically does nothing: it just abuses the context manager protocol to basically make a local variable and indent its usage. Its really just a run-around and slightly less efficient to do: _o = some.deeply.nested.object _o.method(_o.value) But with the whitespace added on. Personally, I'd usually just make a local variable and skip any tricks. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question: Nicknames for deeply nested objects
On Jan 30, 12:23 pm, Stephen Hansen me+list/pyt...@ixokai.io wrote: --- start from contextlib import contextmanager class Item(object): pass deeply = Item() deeply.nested = Item() deeply.nested.thing = Item() @contextmanager def my(thing): yield thing with my(deeply.nested.thing) as o: o.hello = 1 print deeply.nested.thing.hello --- end Well congratulations Stephen, you win the obfuscation prize of the year! -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question: Nicknames for deeply nested objects
On 1/30/11 10:35 AM, rantingrick wrote: Well congratulations Stephen, you win the obfuscation prize of the year! Yes, On 1/30/11 10:09 AM, rantingrick wrote: Here is how a pythonic local block would look with this as localvar: localvar.do_something() verses with my(this) as localvar: localvar.do_something() Is dreadfully more, er, obfuscated. I mean someone would have to know what the 'my' function does to understand what's going on! OH MY GOD. How can someone be expected to understand what a function does! Be serious! You can't expect that of them. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Understanding def foo(*args)
Hi, I am struggling to grasp this concept about def foo(*args). Also, what is def bar(*args, *kwargs)? Isnt it like self must be the first parameter to the method/function? If not what are the exceptions? Also, can the terms method and function be used interchangeably? TIA -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding def foo(*args)
Sorry that parameter is **kwargs. -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding def foo(*args)
On Jan 30, 1:26 pm, sl33k_ ahsanbag...@gmail.com wrote: Hi, I am struggling to grasp this concept about def foo(*args). Also, what is def bar(*args, *kwargs)? FYI: the python intepretor is your friend! py def foo(*args): print args py foo(1) (1,) py foo(1,2,3) (1, 2, 3) py foo(1,[1,23], {'hat':'cat'}) (1, [1, 23], {'hat': 'cat'}) py def bar(*args, **kw): print 'Args:', args print 'Kwds:', kw py bar(1,2,3, hat='cat', spam='eggs') Args: (1, 2, 3) Kwds: {'hat': 'cat', 'spam': 'eggs'} Isnt it like self must be the first parameter to the method/function? If not what are the exceptions? Only *must* with methods! Also, can the terms method and function be used interchangeably? Can the terms cars and truck be used interchangeably? -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding def foo(*args)
sl33k_ wrote: Hi, I am struggling to grasp this concept about def foo(*args). Also, what is def bar(*args, *kwargs)? Isnt it like self must be the first parameter to the method/function? If not what are the exceptions? Also, can the terms method and function be used interchangeably? TIA Try def foo (*args): print 'foo args:', repr (args) foo (1, 2, 3, 4) def bar (*args, **kwargs): print 'bar args:', args print 'bar kwargs:', kwargs bar (1, 2, 3, 4) bar (1, 2, 3, baz=6, boz=None) Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding def foo(*args)
On Sun, Jan 30, 2011 at 11:26 AM, sl33k_ ahsanbag...@gmail.com wrote: Hi, I am struggling to grasp this concept about def foo(*args). The interactive interpreter is your friend! Try experimenting with it next time! http://docs.python.org/tutorial/controlflow.html#arbitrary-argument-lists That `def` defines a variadic function; i.e. a function which takes an arbitrary number of positional arguments. `args` will be a tuple of all the positional arguments passed to the function: def foo(*args): ... print args ... foo(1) (1,) foo(1,2) (1, 2) foo(1,2,3) (1, 2, 3) If positional parameters precede the *-parameter, then they are required and the *-parameter will receive any additional arguments: def qux(a, b, *args): ... print 'a is', a ... print 'b is', b ... print 'args is', args ... qux(1) Traceback (most recent call last): File stdin, line 1, in module TypeError: qux() takes at least 2 arguments (1 given) qux(1, 2) a is 1 b is 2 args is () qux(1, 2, 3) a is 1 b is 2 args is (3,) qux(1, 2, 3, 4) a is 1 b is 2 args is (3, 4) Also, what is def bar(*args, *kwargs)? You meant: def bar(*args, **kwargs) See http://docs.python.org/tutorial/controlflow.html#keyword-arguments Basically, the **-parameter is like the *-parameter, except for keyword arguments instead of positional arguments. Also, can the terms method and function be used interchangeably? No. A method is function that is associated with an object (normally via a class) and takes this object as its first argument (typically named self). A function does not have any of these requirements. Thus, all method are functions, but the reverse is not true. (I'm ignoring complexities like classmethods and staticmethods for simplicity.) Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding def foo(*args)
sl33k_ wrote: Isnt it like self must be the first parameter to the method/function? self is just customary as first parameter to memberfunctions, the language itself doesn't impose this convention, as e.g. C++ does with its this. Also, can the terms method and function be used interchangeably? This distinction doesn't exist in Python. You can put a reference to a free function as attribute in an object. You can store a reference to a bound memberfunction outside the object and call it. Objects and classes here are much more flexible than in C++ or Java. Uli -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question: Nicknames for deeply nested objects
On 30/01/2011 17:51, Gerald Britton wrote: Hi all, Today I was thinking about a problem I often encounter. Say that I have (seems I often do!) a deeply nested object, by which I mean object within object with object, etc. For example: x = some.deeply.nested.object.method(some.other.deeply.nested.object.value) Well, that's extreme but I've worked with code approaching that level of nested-ness. Now, consider two scenarios: 1. You need to call this thing many times with different arguments, so you wind up with: x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1) y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2) z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3) Neither. You should tell. Don't ask if you can avoid it. Compare... queen.getButter() and queen.dairymaid.alderney.getButter() see http://www.timelessteacherstuff.com/readerstheater/KingsBreakfast.pdf king doesn't care where or how the butter is brought. Neither should your code! What are you doing with value1, value2 and value3 when you have them anyway? Stuffing them 3 levels deep into something else? Stop writing procedural code, and write object oriented code instead! If you you make some tell deeply.nested.object about other.deeply.nested.object it can fetch its own values, but it might be better to have some tell other.deeply.nested.object about deeply.nested.object to it can issue the correct commands. Then you tell some to do Somthing by writing some.takeMeaningfullAction() and it all happens under the covers. Regards Ian -- http://mail.python.org/mailman/listinfo/python-list
homedir, file copy
hello, i am trying to work with windows homedirectory as a starting point for some kind of file copy command. i'm testing this on a win7 box so my home is c:\Users\jon\ here is the code snippet i am working on: import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser(~) print homedir print os.listdir(homedir+\\backup\\) homedir.replace( , \\) print homedir shutil.copy (homedir+\\backup\\, homedir+\\backup2\\) output looks like: C:\Users\jon ['test1.txt', 'test2.txt'] C:\Users\jon Traceback (most recent call last): File D:\spring 11\capstone-project\date.py, line 43, in module shutil.copy (homedir+\\backup\\, homedir+\\backup2\\) File C:\Python27\lib\shutil.py, line 116, in copy copyfile(src, dst) File C:\Python27\lib\shutil.py, line 81, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 2] No such file or directory: 'C:\\Users\\jon\\backup\ \' why is there still two \\ in the pathfor the copy command? -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On Jan 30, 2:44 pm, ecu_jon hayesjd...@yahoo.com wrote: shutil.copy (homedir+\\backup\\, homedir+\\backup2\\) TIP: Use os.path.join(x,y, z*) why is there still two \\ in the pathfor the copy command? I always convert my paths to use a single '/' instead of '\\'. Just makes life that much easier! -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On Sun, Jan 30, 2011 at 12:44 PM, ecu_jon hayesjd...@yahoo.com wrote: hello, i am trying to work with windows homedirectory as a starting point for some kind of file copy command. i'm testing this on a win7 box so my home is c:\Users\jon\ here is the code snippet i am working on: import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser(~) print homedir print os.listdir(homedir+\\backup\\) homedir.replace( , \\) print homedir shutil.copy (homedir+\\backup\\, homedir+\\backup2\\) output looks like: C:\Users\jon ['test1.txt', 'test2.txt'] C:\Users\jon Traceback (most recent call last): File D:\spring 11\capstone-project\date.py, line 43, in module shutil.copy (homedir+\\backup\\, homedir+\\backup2\\) File C:\Python27\lib\shutil.py, line 116, in copy copyfile(src, dst) File C:\Python27\lib\shutil.py, line 81, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 2] No such file or directory: 'C:\\Users\\jon\\backup\ \' why is there still two \\ in the pathfor the copy command? There aren't. The error message is just showing the repr() of the string, which involves escaping any literal backslashes in it; note the quotes around the path in the error message. Details on repr(): http://docs.python.org/library/functions.html#repr By way of example: x = raw_input() C:\foo\bar print x C:\foo\bar print repr(x) 'C:\\foo\\bar' print('C:\\foo\\bar') C:\foo\bar Note that you can use forward slashes instead of backslashes in Windows paths in Python, thus avoiding this confusion altogether. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question: Nicknames for deeply nested objects
On Jan 30, 12:53 pm, Stephen Hansen me+list/pyt...@ixokai.io wrote: On 1/30/11 10:35 AM, rantingrick wrote: Well congratulations Stephen, you win the obfuscation prize of the year! Yes, On 1/30/11 10:09 AM, rantingrick wrote: Here is how a pythonic local block would look with this as localvar: localvar.do_something() verses with my(this) as localvar: localvar.do_something() Is dreadfully more, er, obfuscated. Absolutely! I mean someone would have to know what the 'my' function does to understand what's going on! Yes, and also how decorators word and generators work, and ... OH MY GOD. How can someone be expected to understand what a function does! Yes, and also how decorators word and generators work, and ... Be serious! You can't expect that of them. I don't. I don't expect anyone to write 10 lines of obfuscation code when just two will suffice. Maybe you should join the perl group as they would proud! -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question: Nicknames for deeply nested objects
I don't. I don't expect anyone to write 10 lines of obfuscation code when just two will suffice. Maybe you should join the perl group as they would proud! But Stephen's 10 lines of somewhat obscure code actually works, and your two lines of code doesn't. I know which one I would prefer. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question: Nicknames for deeply nested objects
On Sun, 30 Jan 2011 12:51:20 -0500, Gerald Britton wrote: Hi all, Today I was thinking about a problem I often encounter. Say that I have (seems I often do!) a deeply nested object, by which I mean object within object with object, etc. For example: x = some.deeply.nested.object.method (some.other.deeply.nested.object.value) Well, that's extreme but I've worked with code approaching that level of nested-ness. Then you're probably living in a state of sin, programming-wise, and you should stop doing that! You are violating the Law of Demeter. One dot, good. Two, acceptable. Three is a code smell. Four is a code reek. The Law of Demeter (more of a guideline than a law, really) says: If you want to get your dog to walk, call the dog. Don't talk to its legs, it confuses the dog and doesn't get it anywhere. http://en.wikipedia.org/wiki/Law_of_Demeter Another analogy: if you have to pay the paperboy for delivering the newspaper, you don't let him reach into your pocket, take out your wallet, open the wallet, take out whatever money he feels like, and put the wallet back. http://www.ccs.neu.edu/research/demeter/demeter-method/LawOfDemeter/paper- boy/demeter.pdf Despite my comment above, the Law of Demeter is not *really* a dot- counting exercise, although that's a handy short-cut for detecting potential problems. It can also apply to other data structures. If you've every seen C or Pascal code where you have a pointer to a pointer to a pointer to a pointer to a pointer to a pointer to some data, you've seen a violation. Consider your example: some.other.deeply.nested.object.value This is very tightly coupled code: the caller, who knows about the object `some`, needs to know the internal details of not just `some` but also `other`, `deeply`, `nested`, and `object`. As a basic principle, this is poor design! Which would you rather deal with? car.start() car.ignition.turn(key).connect(car.starter(battery), car.spark_plug) In particular, using temporary variables merely disguises the problem: temp = some.other temp = temp.deeply.nested x = temp.object.value Even though you never use more than two dots, you still have tight coupling. The point of Demeter is not to save dots (they're a renewable resource) but to reduce tight coupling. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
Are you a representative voice for all the screen reader users? (Even though most of them use JAWS that you don't seem to like) Newsflash: I didn't say I didn't like Jaws, and I'm using Jaws -right now-. I don't like jaws and see a lot of future for NVDA as it is both free and open source. I like that a lot more than paying what, $1300 or so for a program that will allow me to use the computer? Plus the obligatory $260 for two updates so I can update once every four months, regardless of whether or not I want to update. If you want to rant and scream about accessibility, yell at the people charging an arm and a leg to make things accessible. On 1/28/2011 1:33 AM, Octavian Rasnita wrote: From: Littlefield, Tyler ty...@tysdomain.com * Disclaimer: You are stupid if you think this is true. But seriously, Octavian makes it REALLY hard to continue caring about something that I actually cared about before and thought was important. When I told about what the community of the blind from my country cares, or what I care, the others told me that that is not important. I am sure that won't say the same thing to your post in which you also say about what you care, just because you have the same opinions like them. People like Octavian do that. Sadly, it is one of the things holding the blind community back. I hope that with my arguments (for those that didn't just toss everything related to this thread), I have been able to get people to see a little differently and not consider Octavian as the voice for us all. Who are those us all? Are you a representative voice for all the screen reader users? (Even though most of them use JAWS that you don't seem to like) Or do you agree with the associations of the blind in your country do when they fight with different companies because they make discrimination by not offering accessible products? Or you are more representative than those associations? Octavian -- Thanks, Ty -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding def foo(*args)
sl33k_ ahsanbag...@gmail.com writes: I am struggling to grasp this concept about def foo(*args). Also, what is def bar(*args, *kwargs)? Please work through the Python Tutorial from start to finish URL:http://docs.python.org/tutorial/, performing each exercise and experimenting with it until you understand. You will then have a good grounding in basics of the language like this. -- \ Lucifer: “Just sign the Contract, sir, and the Piano is yours.” | `\ Ray: “Sheesh! This is long! Mind if I sign it now and read it | _o__)later?” —http://www.achewood.com/ | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On Jan 30, 3:55 pm, r rt8...@gmail.com wrote: On Jan 30, 2:44 pm, ecu_jon hayesjd...@yahoo.com wrote: shutil.copy (homedir+\\backup\\, homedir+\\backup2\\) TIP: Use os.path.join(x,y, z*) why is there still two \\ in the pathfor the copy command? I always convert my paths to use a single '/' instead of '\\'. Just makes life that much easier! what does this mean? Use os.path.join(x,y, z*) what is the x,y,z? -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On Sun, Jan 30, 2011 at 3:13 PM, ecu_jon hayesjd...@yahoo.com wrote: On Jan 30, 3:55 pm, r rt8...@gmail.com wrote: On Jan 30, 2:44 pm, ecu_jon hayesjd...@yahoo.com wrote: shutil.copy (homedir+\\backup\\, homedir+\\backup2\\) TIP: Use os.path.join(x,y, z*) why is there still two \\ in the pathfor the copy command? I always convert my paths to use a single '/' instead of '\\'. Just makes life that much easier! what does this mean? Use os.path.join(x,y, z*) what is the x,y,z? See http://docs.python.org/library/os.path.html#os.path.join e.g. in your case: backupdir = os.path.join(homedir, backup) Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On Jan 30, 5:13 pm, ecu_jon hayesjd...@yahoo.com wrote: what does this mean? Use os.path.join(x,y, z*) what is the x,y,z? x,y, and z in this case are just generic variables. Consider x+y=10. x and y could both equal 5 or any number of combinations of two numbers who sum equals ten. Anyway see the link chris posted to the docs or fire up your python shell and try this... import sys sys.version_info (2, 6, 5, 'final', 0) # yours may be different! folder = 'C:/somepath/to/folder' filename = 'somefile.txt' import os help(os.path.join) Help on function join in module ntpath: join(a, *p) Join two or more pathname components, inserting \ as needed. If any component is an absolute path, all previous path components will be discarded. os.path.join(folder, filename) 'C:/somepath/to/folder\\somefile.txt' help(os.path.normpath) Help on function normpath in module ntpath: normpath(path) Normalize path, eliminating double slashes, etc. os.path.normpath(os.path.join(folder, filename)) 'C:\\some\\path\\to\\folder\\somefile.txt' psst: i know what you're thinking... and yes, python is very cool! -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
ok now i get permission denied import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser(~) print homedir print os.listdir(homedir+\\backup\\) #homedir.replace( , \\) #print homedir backupdir1 = os.path.join(homedir, backup) backupdir2 = os.path.join(homedir, backup2) shutil.copy (backupdir1, backupdir2) -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On Jan 28, 9:15 am, Littlefield, Tyler ty...@tysdomain.com wrote: If you want to rant and scream about accessibility, yell at the people charging an arm and a leg to make things accessible. You make a good point as we could always use more opensource, free, and reasonably priced software. However unless the GUI library in question supports accessibility, it really won't matter how much the tool costs if you cannot use it! Consider if automobiles were free however gasoline was obsolete. -- rr: spreading common sense like an incurable virus. -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On 30/01/2011 23:43, ecu_jon wrote: ok now i get permission denied import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser(~) print homedir print os.listdir(homedir+\\backup\\) #homedir.replace( , \\) #print homedir backupdir1 = os.path.join(homedir, backup) backupdir2 = os.path.join(homedir, backup2) shutil.copy (backupdir1, backupdir2) shutil.copy(...) copies files, not directories. You should use shutil.copytree(...) instead. -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On Jan 30, 7:09 pm, MRAB pyt...@mrabarnett.plus.com wrote: On 30/01/2011 23:43, ecu_jon wrote: ok now i get permission denied import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser(~) print homedir print os.listdir(homedir+\\backup\\) #homedir.replace( , \\) #print homedir backupdir1 = os.path.join(homedir, backup) backupdir2 = os.path.join(homedir, backup2) shutil.copy (backupdir1, backupdir2) shutil.copy(...) copies files, not directories. You should use shutil.copytree(...) instead. i will, closer towards the end. just wanted to get past the naming stuff, the problem above. right now i just want to see it move files from 1 place to another. i had copytree in before, and will go back to that for final version. im working on a backup program, and copytree looks yummy. still no idea why getting permission denied. -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On 01/-10/-28163 02:59 PM, ecu_jon wrote: ok now i get permission denied import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser(~) print homedir print os.listdir(homedir+\\backup\\) #homedir.replace( , \\) #print homedir backupdir1 = os.path.join(homedir, backup) backupdir2 = os.path.join(homedir, backup2) shutil.copy (backupdir1, backupdir2) You forgot to include the error traceback. So, is homedir/backup a file, or is it a directory? If you're trying to copy whole directories, you might want to look at copytree instead. If you're not sure, you could use os.isfile() to check. If that's false, then shutil.copy() can't work. Similarly, if the destination is a readonly file, you'd get some error. DaveA -- http://mail.python.org/mailman/listinfo/python-list
MS Access table values as input into a formula in another table-need help!!
Dear Python Community, Table1: Prop_codeR_Value GC 0.8 CI 0.6 LDR 0.4 HDR 0.6 TR 0.65 CR 0.35 Table 2: O_ID PROP_CODE AI TArea R_Value Pre_R_Value IR MER02006 LDR 38.19235 132.3178 0.4 0.115456 0.555143 MER02006 TR 20.78983 132.3178 0.65 0.102128 0.555143 MER02006 UO 1.850129 132.3178 0.25 0.003496 0.555143 MER03001 GC 16.565 137.592 0.8 0.096314 0.45027 Initially, I manually entered R_Value from table 1 into table 2 in order to later compute subsequent fields using Python. Now I’d like to make the process a bit more automatic. I would like to get R_Values for each Prop_Code from table 1 into table 2 so that I can use them in a Table2 computation later on. I was thinking maybe a putting table 1 into a dict then use those values in table 2, but I need help getting started. Just learning Python and dicts are still tricky for me. Please help me modify the code below so that i don't have to repeat the lines of code below for all values of Prop_Code: import arcpy,sys arcpy.env.workspace = C:\\test\\DRAINAGE.mdb Table1= basins Table2=CV_Table cur = arcpy.UpdateCursor(table2, [PROP_CODE] = 'LDR') row = cur.next() # Perform the update and move to the next row as long as there are # rows left while row: row.R_Value = 0 #initialize field from nulls to zero values row.R_Value = 0.4 #INstead, I need to get this from Table 2 cur.updateRow(row) row = cur.next() # Delete the cursors to remove any data locks del row, cur THANKS!! -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On Jan 30, 7:19 pm, Dave Angel da...@ieee.org wrote: On 01/-10/-28163 02:59 PM, ecu_jon wrote: ok now i get permission denied import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser(~) print homedir print os.listdir(homedir+\\backup\\) #homedir.replace( , \\) #print homedir backupdir1 = os.path.join(homedir, backup) backupdir2 = os.path.join(homedir, backup2) shutil.copy (backupdir1, backupdir2) You forgot to include the error traceback. So, is homedir/backup a file, or is it a directory? If you're trying to copy whole directories, you might want to look at copytree instead. If you're not sure, you could use os.isfile() to check. If that's false, then shutil.copy() can't work. Similarly, if the destination is a readonly file, you'd get some error. DaveA today's date is : 30 week chosen is : 4 C:\Users\jon ['test1.txt', 'test2.txt'] Traceback (most recent call last): File D:\spring 11\capstone-project\date.py, line 45, in module shutil.copy (backupdir1, backupdir2) File C:\Python27\lib\shutil.py, line 116, in copy copyfile(src, dst) File C:\Python27\lib\shutil.py, line 81, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 13] Permission denied: 'C:\\Users\\jon\\backup' -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On Jan 30, 5:43 pm, ecu_jon hayesjd...@yahoo.com wrote: ok now i get permission denied [...] shutil.copy (backupdir1, backupdir2) I must stress the importance of proper testing before ever running code that manipulates files! So many things can go wrong. Of course you are just copying files here and not deleting them however you must always be in the habit of treating files like explosives. And frankly you're being quite nonchalant with this very naive approach to coding and complete lack of testing. When handling files always test, test, test. Never actually move, copy, or delete until you are *absolutely* sure no failures will occur. I will always do test runs that print out the action but DO NOT actually DO the action, like... Copying files: -- from: C:\\somefile1 to: C:\\blah\\somefile1 -- from: C:\\somefile2 to: C:\\blah\\somefile2 -- from: C:\\somefile3 to: C:\\blah\\somefile3 -- etc... Once my test runs are bug free i can try to move or delete *one* file from some test set. Once that is bug free then i will try the code on many files of a test set, and ONLY THEN on the real thing. I guarantee if you keep manipulating files in such a haphazard way you will live to regret it! -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On Jan 30, 7:34 pm, rantingrick rantingr...@gmail.com wrote: On Jan 30, 5:43 pm, ecu_jon hayesjd...@yahoo.com wrote: ok now i get permission denied [...] shutil.copy (backupdir1, backupdir2) I must stress the importance of proper testing before ever running code that manipulates files! So many things can go wrong. Of course you are just copying files here and not deleting them however you must always be in the habit of treating files like explosives. And frankly you're being quite nonchalant with this very naive approach to coding and complete lack of testing. When handling files always test, test, test. Never actually move, copy, or delete until you are *absolutely* sure no failures will occur. I will always do test runs that print out the action but DO NOT actually DO the action, like... Copying files: -- from: C:\\somefile1 to: C:\\blah\\somefile1 -- from: C:\\somefile2 to: C:\\blah\\somefile2 -- from: C:\\somefile3 to: C:\\blah\\somefile3 -- etc... Once my test runs are bug free i can try to move or delete *one* file from some test set. Once that is bug free then i will try the code on many files of a test set, and ONLY THEN on the real thing. I guarantee if you keep manipulating files in such a haphazard way you will live to regret it! not nonchalant. i know i will ned to do testing and whatnot. just personally, i like to build stuff one concept at a time. for example, i had a problem with the homedir and peopel here helped me with that. now i have permissions problem, and an swer will likely meeerge. once i know how to copy a file, ill work on testing. like isfile and permissions. i know that has to be done. i guess its that you want tests before moves , and thats fine. since i have only ever had 1 python class, and basically learning this whole thing from scratch, i need to do things 1 step at a time. so now any thoughts on why i cannot write to my own homedir? -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
It seems like you are trying to copy directories with shutil.copy. Use shutil.copytree instead. On Sun, 2011-01-30 at 16:43 -0800, ecu_jon wrote: On Jan 30, 7:34 pm, rantingrick rantingr...@gmail.com wrote: On Jan 30, 5:43 pm, ecu_jon hayesjd...@yahoo.com wrote: ok now i get permission denied [...] shutil.copy (backupdir1, backupdir2) I must stress the importance of proper testing before ever running code that manipulates files! So many things can go wrong. Of course you are just copying files here and not deleting them however you must always be in the habit of treating files like explosives. And frankly you're being quite nonchalant with this very naive approach to coding and complete lack of testing. When handling files always test, test, test. Never actually move, copy, or delete until you are *absolutely* sure no failures will occur. I will always do test runs that print out the action but DO NOT actually DO the action, like... Copying files: -- from: C:\\somefile1 to: C:\\blah\\somefile1 -- from: C:\\somefile2 to: C:\\blah\\somefile2 -- from: C:\\somefile3 to: C:\\blah\\somefile3 -- etc... Once my test runs are bug free i can try to move or delete *one* file from some test set. Once that is bug free then i will try the code on many files of a test set, and ONLY THEN on the real thing. I guarantee if you keep manipulating files in such a haphazard way you will live to regret it! not nonchalant. i know i will ned to do testing and whatnot. just personally, i like to build stuff one concept at a time. for example, i had a problem with the homedir and peopel here helped me with that. now i have permissions problem, and an swer will likely meeerge. once i know how to copy a file, ill work on testing. like isfile and permissions. i know that has to be done. i guess its that you want tests before moves , and thats fine. since i have only ever had 1 python class, and basically learning this whole thing from scratch, i need to do things 1 step at a time. so now any thoughts on why i cannot write to my own homedir? -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On 31/01/2011 00:18, ecu_jon wrote: On Jan 30, 7:09 pm, MRABpyt...@mrabarnett.plus.com wrote: On 30/01/2011 23:43, ecu_jon wrote: ok now i get permission denied import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser(~) print homedir print os.listdir(homedir+\\backup\\) #homedir.replace( , \\) #print homedir backupdir1 = os.path.join(homedir, backup) backupdir2 = os.path.join(homedir, backup2) shutil.copy (backupdir1, backupdir2) shutil.copy(...) copies files, not directories. You should use shutil.copytree(...) instead. i will, closer towards the end. just wanted to get past the naming stuff, the problem above. right now i just want to see it move files from 1 place to another. i had copytree in before, and will go back to that for final version. im working on a backup program, and copytree looks yummy. still no idea why getting permission denied. The path given by backupdir1 is a directory, so you're trying to use shutil.copy(...) to copy a directory. The reason that it's complaining about permissions is that shutil.copy is trying to open the source file (look at the traceback) so that it can copy the file's contents, but it's not a file, it's a directory. CPython is written in C, so it's probably the underlying C library which is reporting it as a permissions problem instead of a that's not a file! problem. :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???
On Jan 30, 10:35 pm, rusi rustompm...@gmail.com wrote: On Jan 30, 6:31 pm, bansi mail2ba...@gmail.com wrote: Isn't it possible to implement your suggestion without installing Visual C++ 2008 . http://code.google.com/p/pyodbc/wiki/Building#Windows Well... This is what the official site says... On second thoughts I wonder: Would it not be possible to compile python +pyodbc from source and use gcc/ming for that? Someone who knows more of the windows build process may say something about the issues involved. -- http://mail.python.org/mailman/listinfo/python-list
Limit on entries in dictionary data structure
Hi, I am running a script that uses dictionaries on Python 2.6.4 on Ubuntu 9.10. I notice that my script crashes with a MemoryError when my dictionary reaches 44739243th entry. My system has 3GB RAM (32-bit). I noticed that changing the key or value types also did not help my code. For simplicity I tried running this: #BEGIN:python code import sys f={} lsize=0 try: for k in range(0,4*44739243): f[k]=k if sys.getsizeof(f) lsize: lsize = sys.getsizeof(f) print k, lsize except: print k, lsize raise #END:python code The code terminates with: Traceback (most recent call last): File pydict-limit.py, line 6, in module f[k]=k MemoryError I have also tried running this on Ubuntu 9.10 with Python 2.6.6 with 3.5GB RAM(32-bit) and a 64-bit LINUX cluster machine with 62GB RAM and Python 2.4. On both these machines it crashed at entry 44739243. The size of the data structure grows to 1.5GB. On another 64-bit cluster machine with 32GB RAM and Python 2.6.6 it crashed at entry 178956970. In this case the size of the data structure grew to 6GB. Has anybody encountered this before? Can somebody suggest any fix for this? I am trying to read some 10GB network traces into a hash table(hence dictionary) and need constant time lookup. Clearly increasing the machine RAM does not work. Any suggestions would be greatly appreciated. Thanks, Shruti -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On Jan 30, 8:25 pm, MRAB pyt...@mrabarnett.plus.com wrote: On 31/01/2011 00:18, ecu_jon wrote: On Jan 30, 7:09 pm, MRABpyt...@mrabarnett.plus.com wrote: On 30/01/2011 23:43, ecu_jon wrote: ok now i get permission denied import os homedir = os.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir = os.path.expanduser(~) print homedir print os.listdir(homedir+\\backup\\) #homedir.replace( , \\) #print homedir backupdir1 = os.path.join(homedir, backup) backupdir2 = os.path.join(homedir, backup2) shutil.copy (backupdir1, backupdir2) shutil.copy(...) copies files, not directories. You should use shutil.copytree(...) instead. i will, closer towards the end. just wanted to get past the naming stuff, the problem above. right now i just want to see it move files from 1 place to another. i had copytree in before, and will go back to that for final version. im working on a backup program, and copytree looks yummy. still no idea why getting permission denied. The path given by backupdir1 is a directory, so you're trying to use shutil.copy(...) to copy a directory. The reason that it's complaining about permissions is that shutil.copy is trying to open the source file (look at the traceback) so that it can copy the file's contents, but it's not a file, it's a directory. CPython is written in C, so it's probably the underlying C library which is reporting it as a permissions problem instead of a that's not a file! problem. :-) as for testing i was planning on using something like this http://docs.python.org/library/shutil.html scroll down to 10.10.1.1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Style question: Nicknames for deeply nested objects
On 1/30/11 1:13 PM, rantingrick wrote: On Jan 30, 12:53 pm, Stephen Hansen me+list/pyt...@ixokai.io wrote: OH MY GOD. How can someone be expected to understand what a function does! Yes, and also how decorators word and generators work, and ... Be serious! You can't expect that of them. I don't. I don't expect anyone to write 10 lines of obfuscation code when just two will suffice. Maybe you should join the perl group as they would proud! Riiight. suffice doesn't mean what you think it means. Generally, if something suffices -- it actually, you know, ... works. My four lines of setup can get put into a library and treated as a recipe if they don't want to get into understanding generators or decorators: then its two lines to use, and those two lines are exactly like your two lines except for two little details: 1. They add a function call to the syntax. 2. They actually work. The OP doesn't have to understand decorators or generators if he doesn't want to: though I encourage him to do so, as they are beautiful and elegant tools that can very clearly and concisely help solve a lot of problems. Now, me? I wouldn't use the recipe, as I originally said in my response. I'd just use a local variable. But the OP didn't like that, and he wanted some indenting and whitespace to clearly demarcate where he intended to use the local. So I gave him a way to do that. You gave him... uh, what was it again? Oh, right. Nothing. As usual. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: homedir, file copy
On 01/-10/-28163 02:59 PM, ecu_jon wrote: On Jan 30, 7:19 pm, Dave Angelda...@ieee.org wrote: On 01/-10/-28163 02:59 PM, ecu_jon wrote: ok now i get permission denied import os homedir =s.path.expanduser('~') try: from win32com.shell import shellcon, shell homedir =hell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) except ImportError: homedir =s.path.expanduser(~) print homedir print os.listdir(homedir+\\backup\\) #homedir.replace( , \\) #print homedir backupdir1 =s.path.join(homedir, backup) backupdir2 =s.path.join(homedir, backup2) shutil.copy (backupdir1, backupdir2) You forgot to include the error traceback. So, is homedir/backup a file, or is it a directory? If you're trying to copy whole directories, you might want to look at copytree instead. If you're not sure, you could use os.isfile() to check. If that's false, then shutil.copy() can't work. Similarly, if the destination is a readonly file, you'd get some error. DaveA today's date is : 30 week chosen is : 4 C:\Users\jon ['test1.txt', 'test2.txt'] Traceback (most recent call last): File D:\spring 11\capstone-project\date.py, line 45, inmodule shutil.copy (backupdir1, backupdir2) File C:\Python27\lib\shutil.py, line 116, in copy copyfile(src, dst) File C:\Python27\lib\shutil.py, line 81, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 13] Permission denied: 'C:\\Users\\jon\\backup' Good job, reading the first part of my message. Now, why are you saying in other messages that it can't write to your home directory? The error doesn't refer to your home directory, it refers to a file C:\Users\jon\backup which it can't read. But as your program demonstrates, that's a directory not a file. It's fine to use shutil.copy, but then you have to give it a source file to copy. For example, C:\Users\jon\backup\test1.txt DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple values for keyword argument
Well - this is all timely email. I just spent the day configuring my HP mini netbook running Windows 7 with all the right software based on recomendations from folks on this list, from the Python Tutor list and an email group of former colleagues where I spelled out exactly all the programming languages and stuff I ideally wanted. It has been very enlightening and actually not so difficult! Asking pays off! And I made a few realizations - I had some misperceptions about some software packages and -- I had been thinking about this 'self' business since yesterday. And you and Ethan and Ben Finney from yesterday (the last email msg I read last night, might know) are right -- I was being stubborn and wanting to do things *my* way and I was telling myself that when it comes time to do this for a future employer, well I will just change my code in the appropriate places to 'self' and will start using 'self' when I start working for them. And a little thought in the back of my head ... I wonder if the employer would be a little annoyed by that :) OK - I need my hand slapped sometimes and I see that you all are trying to prevent me from developing a bad habit. A few comments below: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote in message news:4d453127$0$29965$c3e8da3$54964...@news.astraweb.com... On Sat, 29 Jan 2011 10:39:49 -0800, patty wrote: I am glad you said this. I have been avoiding understanding this 'self', just accepting it :} For the time being, since my programs I am creating are for my own use, I think I will make my own names up, that are descriptive to me as the programmer, it's all going to be interpreted anyway. And the other email equating to C's argv, etc. - now I get it. That's a shame, because `self` is actually very simple once you understand the basic principles of object-oriented programming. What names would you choose? Unless you're writing descriptors, or using class methods, both of which should be considered advanced usage (highly advanced for descriptors, moderately so for class methods), it's not like every method needs a different descriptive first argument. In English, self, this, me or instance would be good names. What else would you use? That is the thing, I can get quite creative. I envisioned myself giving it a name something like 'instancecalledfrommain' probably scrunched up to 'instfrmmain' Weird descriptive names like that. I keep thinking of it as a variable, so I keep thinking of what it is used for underlying its name. Back to the I-can-do-anything-I-want mindset. I have saved the messages in this thread and other ones from the last month or so about 'self' so I think I will gather them together and read them more carefully including your very good explanations below. The idea of method syntax is that you start with an instance of some class: mystring = hello world # an instance of the str class In procedural languages like C or Pascal, you would call a function and give the string as an argument. Python supports this programming model, and uses it for built-ins like len: len(mystring) = returns 11 And I am more comfortable in the C and Pascal worlds as a base so I see why I go this direction. Object oriented programming uses a different syntax. Instead of function(instance) as above, we take the instance argument outside the brackets. For example: mystring.upper() # instead of upper(mystring) = returns HELLO WORLD If there are any extra arguments needed, they go inside the brackets as normal. So far, this is just a change of syntax. It's like saying The cat of my brother's vs. my brother's cat -- the meaning is the same, but the syntax differs. And I am a linguist so now you are Really talking ;) The real advantages of object oriented programming and methods come elsewhere (e.g. encapsulation and inheritance). [Aside: when I was learning this, the hardest part I found was remembering which things were functions, and which were methods. I kept writing (wrongly!) things like: hello world.len() upper(hello world) Unfortunately there is no easy way to recognise what will be a function like len, and which are methods like upper. That will come with experience. Oh! I do this! I seem to use this syntax interchangably. I really need to memorize this carefully. Back to function/procedural syntax versus object oriented syntax... One difference, though, is when you write a method definition. Because the method you write starts off life as an ordinary function, you need to write it *as if* it were a function you call like len() above. Here's how you might write a method in a class: class MyClass: def method(self, extra): pass When you then call the method: instance = MyClass() instance.method(something extra) Python automatically changes the
Re: Understanding def foo(*args)
On Jan 31, 12:35 am, rantingrick rantingr...@gmail.com wrote: Also, can the terms method and function be used interchangeably? Can the terms cars and truck be used interchangeably? Oooff! A load of meaning in that one line -- I wonder though if the OP will understand... -- http://mail.python.org/mailman/listinfo/python-list
Useing the processor clock, or get time in Femptoseconds
Does anyone have any suggestions? -- http://mail.python.org/mailman/listinfo/python-list
Re: Limit on entries in dictionary data structure
On 31/01/2011 02:43, Shruti Sanadhya wrote: Hi, I am running a script that uses dictionaries on Python 2.6.4 on Ubuntu 9.10. I notice that my script crashes with a MemoryError when my dictionary reaches 44739243th entry. My system has 3GB RAM (32-bit). I noticed that changing the key or value types also did not help my code. For simplicity I tried running this: #BEGIN:python code import sys f={} lsize=0 try: for k in range(0,4*44739243): f[k]=k if sys.getsizeof(f) lsize: lsize = sys.getsizeof(f) print k, lsize except: print k, lsize raise #END:python code The code terminates with: Traceback (most recent call last): File pydict-limit.py, line 6, in module f[k]=k MemoryError I have also tried running this on Ubuntu 9.10 with Python 2.6.6 with 3.5GB RAM(32-bit) and a 64-bit LINUX cluster machine with 62GB RAM and Python 2.4. On both these machines it crashed at entry 44739243. The size of the data structure grows to 1.5GB. On another 64-bit cluster machine with 32GB RAM and Python 2.6.6 it crashed at entry 178956970. In this case the size of the data structure grew to 6GB. Has anybody encountered this before? Can somebody suggest any fix for this? I am trying to read some 10GB network traces into a hash table(hence dictionary) and need constant time lookup. Clearly increasing the machine RAM does not work. Any suggestions would be greatly appreciated. sys.getsizeof(...) returns the size of an object itself, not the size of an object plus any others which that object references. The dict in your example code occupied 1.5GB, but that didn't include the size of the int keys and values, only the references to them. As for the 64-bit Linux cluster machine, did you run a 32-bit or a 64-bit build of Python? A 32-bit build can't use more than 4GB (2**32). -- http://mail.python.org/mailman/listinfo/python-list
Re: Useing the processor clock, or get time in Femptoseconds
If you are on windows, you can use high-resolution timers. What you are trying is physically impossible though: lets say you have a processor that runs at 2.5 GHz. that's 2.5 billion cycles per second, give or take a few. So, the lowest you can go is nanoseconds. You're trying to time like 10x the processor's actual speed, and you're not going to get timing that good. so, lower your bar a bit; the highest you will get is nanoseconds with high-res timers. (I'm not sure what the equivalent of this is on *nix, or whether or not python supports it on either platform. I think you'll end up making a DLL call, though I could be wrong). -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
rantingrick rantingr...@gmail.com wrote: To be honest, i would sacrifice all the functionality of wxWidgets if we could get pyGUI into the stdlib. Why? Well because pyGUI would be under OUR complete control. You would need to contribute something other than bullshit and vitriol in order to be able to use the word our in the way you do here. *if* the community saw the potential that i see with pyGUI and wanted to seriously do some development to bring it into 3.0 compliance i'll bet Greg *would* be interested You can't even generate your _own_ code for this idea and yet you somehow mystically know how other people will respond? Have you _ever_ been even _close_ to being able to do this? You seem genuinely angry and shocked at times that we haven't embraced you as some kind of messianic firebrand, which doesn't really say a lot for your ability to gauge the responses desires of others. Maybe Greg's not a complete egotist like yourself, needing the attention and constant fluffing you seem to demand before you'll even begin to consider coding. Maybe pyGUI as is scratches his itch, because rather than spending YEARS trying to offload work onto the community he just coded up what he needed to actually get something _done_, something other than masturbating over a library for its own sake. Maybe he has no interest in 3.x but has no concern with community submitted patches. A patch - I should probably explain for your sake, rick - is a diff of changes to a body of code allowing the project maintainer to integrate user submitted bug fixes and feature additions. Pretty much most project maintainers will accept them sans manifesto too. This isn't about getting your ego stroked. This isn't about which language's dick is the longest because it has its own GUI. This is about people with lives of their own making small contributions born of necessity culminating in the further growth evolution of a useful piece of code. -- http://mail.python.org/mailman/listinfo/python-list
Re: Limit on entries in dictionary data structure
On Sun, Jan 30, 2011 at 6:43 PM, Shruti Sanadhya s.sanad...@gmail.com wrote: Hi, I am running a script that uses dictionaries on Python 2.6.4 on Ubuntu 9.10. I notice that my script crashes with a MemoryError when my dictionary reaches 44739243th entry. My system has 3GB RAM (32-bit). I noticed that changing the key or value types also did not help my code. For simplicity I tried running this: #BEGIN:python code import sys f={} lsize=0 try: for k in range(0,4*44739243): f[k]=k if sys.getsizeof(f) lsize: lsize = sys.getsizeof(f) print k, lsize except: print k, lsize raise #END:python code The code terminates with: Traceback (most recent call last): File pydict-limit.py, line 6, in module f[k]=k MemoryError I have also tried running this on Ubuntu 9.10 with Python 2.6.6 with 3.5GB RAM(32-bit) and a 64-bit LINUX cluster machine with 62GB RAM and Python 2.4. On both these machines it crashed at entry 44739243. The size of the data structure grows to 1.5GB. On another 64-bit cluster machine with 32GB RAM and Python 2.6.6 it crashed at entry 178956970. In this case the size of the data structure grew to 6GB. Has anybody encountered this before? Can somebody suggest any fix for this? I am trying to read some 10GB network traces into a hash table(hence dictionary) and need constant time lookup. Clearly increasing the machine RAM does not work. Any suggestions would be greatly appreciated. Thanks, Shruti If you need strict controls over how much memory is used, you might be better off with C or something. Or Cython would give you a Pythonic syntax with C's datastructures (as well as Python-style datastructures, but that gets back into memory unpredictability). On an Ubuntu system, you can probably man hcreate to get some info on a hash table accessible from C. If you need a huge dictionary, then using something like gdbm or bsddb might be good, though I doubt these are constant time - they're more like single-table databases, where the keys and values must all be strings or serialized non-strings. However, they should be fine with huge dictionaries. They have the advantage of providing a pretty dictionary-like interface. This almost certainly would not bump into any memory limits, as they are disk-based. If you really do need to keep things in RAM (VM), you might try this module: http://stromberg.dnsalias.org/~strombrg/treap/ on one of your 64 bit systems, preferably with a recent cpython like 2.6 or 2.7 built with a 64 bit compiler. It too is not constant time, but it is O(c*log(n)) with a small c, at the expense of a higher standard deviation in write times compared to something like a red/black tree (better average performance though). This provides a very dictionary-like interface. It would implicitly store things sorted by key, incidentally, though that may be unimportant in your application. This may or may not have the same memory issues as the dictionary - and I'd be very interested in hearing whether they do or not. You might also be able to read everything into a big list, then sort it. Then use the bisect module to do log(n) time lookups. This does not give a dictionary-like interface or constant time, but it doesn't require anything outside of CPython's standard library. It may or may not have the same memory issues you were seeing with dictionaries. Here's something based on your code above, that works with the mentioned treap module. I found that it required about 1 gig for each 10% of the numbers the code was trying to save - on a 32 bit, Ubuntu 10.10 system. However, I have only 3 gig of RAM, so I terminated it before it got to a memory error: #!/usr/bin/python import sys import treap f = treap.treap() top = 4*44739243 try: for k in xrange(0, top): sys.stdout.write('%d %f%%\r' % (k, k * 100.0 / top)) f[k]=k print except: print raise -- http://mail.python.org/mailman/listinfo/python-list
Re: Useing the processor clock, or get time in Femptoseconds
On 1/30/2011 8:14 PM, Littlefield, Tyler wrote: If you are on windows, you can use high-resolution timers. What you are trying is physically impossible though: lets say you have a processor that runs at 2.5 GHz. that's 2.5 billion cycles per second, give or take a few. So, the lowest you can go is nanoseconds. You're trying to time like 10x the processor's actual speed, and you're not going to get timing that good. so, lower your bar a bit; the highest you will get is nanoseconds with high-res timers. (I'm not sure what the equivalent of this is on *nix, or whether or not python supports it on either platform. I think you'll end up making a DLL call, though I could be wrong). On x86 CPUs since the Pentium, you can read the CPU's cycle counter, which is incrementing once for each clock cycle, maybe every 300ps or so on a current generation CPU. See http://en.wikipedia.org/wiki/Time_Stamp_Counter; You do not want to do this. First, you're in Python, which is interpreted; picosecond level timing resolution is orders of magnitude finer than is meaningful at the Python source level. Second, on multiprocessors, each CPU has its own cycle clock, and they're not synchronized. Third, on superscalar CPUs, reading of the clock may occur out of order and be meaningless. In Python, just call time.time(), which gets you a floating point number with about 1ms resolution. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Bugs/issues in tkinter.simpledialog!!
rantingrick rantingr...@gmail.com wrote: Actually i see you point but there is a good reason behind me bringing this up here. I want to bring to the attention of everyone how little interest there is for Tkinter. Right. You have no interest in resolving this issue and instead want to use it as more ammunition in your ongoing crusade. You even have the gall to act _offended_ at Giampaolo's suggestion that you log the bug, dumping your usual bullshit and vitriol on someone WHO HAS ACTUALLY DONE THE SORT OF WORK YOU CONSTANTLY CLAIM YOU'RE GOING TO, even though your every intention was to parade this issue around as if it somehow validates your personal blend of crazy. You're a class act, that's for sure. Agreed. However i would rather just write a patch, send it to some email and be done. Or just commit the changes myself. This bug tracker is just bureaucracy at it's worst. You are making this process too hard and people are not going to get involved when they have to jump through 20 hoops just to patch three lines of freaking code! Because complex distributed coding projects should be treated like Wikipedia? It must suck being such a genius and yet be unable to grapple with a simple bug tracker... -- http://mail.python.org/mailman/listinfo/python-list
[issue10845] test_multiprocessing failure under Windows
Changes by Georg Brandl ge...@python.org: -- priority: release blocker - critical ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11069] IDLE crashes when Stack Viewer opened
Georg Brandl ge...@python.org added the comment: Thanks, applied in r88258. -- nosy: +georg.brandl resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11069 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10961] Pydoc touchups in new browser for 3.2
Georg Brandl ge...@python.org added the comment: I fixed two instances of missing HTML escaping and committed as r88261. The code should be checked thoroughly for more such missing escaping. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10961 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11051] system calls per import
Changes by Nadeem Vawda nadeem.va...@gmail.com: -- nosy: +nvawda ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11051 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11051] system calls per import
Martin v. Löwis mar...@v.loewis.de added the comment: Something has gone out of control here. Why do we need to check so many alternative locations? What change do you propose? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11051 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11051] system calls per import
Changes by Raymond Hettinger rhettin...@users.sourceforge.net: -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11051 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11051] system calls per import
Changes by Georg Brandl ge...@python.org: -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11051 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11051] system calls per import
Antoine Pitrou pit...@free.fr added the comment: Something has gone out of control here. Why do we need to check so many alternative locations? What change do you propose? First, I don't understand why we need to check both foo.so and foomodule.so. Second, I don't understand why we need to check both foo.cpython32.so and foo.so. If you fix both these, the number of stat() calls per would-be extension module goes down from 6 to 2 per directory path. Then there seems to be a couple of redundant stat/fstat calls on some files. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11051 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)
Steven Bethard steven.beth...@gmail.com added the comment: Looks great, thanks. I've updated the patch so it applies okay to both release27-maint and py3k. All tests pass on both branches. It's a one line fix and the test case looks good, so there should be no problem applying this to release27-maint. For 3.2, the py3k branch is frozen for rc2, and Georg has said that he hopes for zero commits between rc2 and final. If anyone feels very strongly about this getting into 3.2, please ask Georg for permission. -- assignee: - bethard stage: unit test needed - patch review Added file: http://bugs.python.org/file20617/issue10680_withTestcase.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10680 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)
Changes by Steven Bethard steven.beth...@gmail.com: Removed file: http://bugs.python.org/file20548/issue10680_withTestcase.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10680 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)
Changes by Steven Bethard steven.beth...@gmail.com: Removed file: http://bugs.python.org/file20114/argparse.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10680 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)
Georg Brandl ge...@python.org added the comment: I haven't started yet actually releasing, so this got in as r88263. -- nosy: +georg.brandl resolution: - fixed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10680 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7502] All DocTestCase instances compare and hash equal to each other
Cédric Krier cedric.kr...@b2ck.com added the comment: Here is a patch that defines __eq__ and __hash__ on DocTestCase. -- keywords: +patch nosy: +ced Added file: http://bugs.python.org/file20618/doctestcase_eq_hash.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7502 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11069] IDLE crashes when Stack Viewer opened
Brian Curtin cur...@acm.org added the comment: This should be back-ported to the maintenance branch as well. I can take care of that if Georg is busy with release-related stuff. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11069 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)
Steven Bethard steven.beth...@gmail.com added the comment: Awesome, thanks! Do you want to apply to 2.7 or should I? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10680 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11071] What's New review comments
New submission from Nick Coghlan ncogh...@gmail.com: Reviewing the What's New docs, this seemed like the easiest way to give Raymond a list of things I noticed: - first sentence in the ast module section needs rewording (currently includes fragments from a couple of different phrasings) - in the dis module section, dis.dis has also acquired the ability to disassemble source string directly, avoiding the need to compile them manually first (see issue 6507). - in the dbm module section, there is another case of a sentence containing fragments from two different phrasings - the new handler of last resort functionality in the logging module deserves a mention (see issue 10626 and the explanation at http://docs.python.org/dev/howto/logging.html#what-happens-if-no-configuration-is-provided) - Vinay's rewrite of the logging module docs to be significantly more approachable (by splitting them into the raw logging API docs and the read-as-much-as-you-need-to logging HOWTO) is also a notable and welcome change. -- assignee: rhettinger components: Documentation messages: 127529 nosy: ncoghlan, rhettinger priority: normal severity: normal status: open title: What's New review comments versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11071] What's New review comments
Nick Coghlan ncogh...@gmail.com added the comment: A couple more in the Build and CAPI section: - The is a new function should be There is a new function - The PyUnicode_CompareWithASCIIString() now either needs to drop the The or add function before the now. It's fascinating to read all that and realise how much actually has been done since 3.1 came out. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)
Georg Brandl ge...@python.org added the comment: Please do. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10680 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11069] IDLE crashes when Stack Viewer opened
Georg Brandl ge...@python.org added the comment: Please do. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11069 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11023] pep 227 missing text
Alan Isaac alan.is...@gmail.com added the comment: Bear with my confusion about your response. Are you saying that CPython documentation bugs cannot be submitted here, or that this does not constitute a CPython documentation bug? I assume the latter. But then, can you tell me where to find the correct CPython documentation after I read the following quote from PEP 277? http://www.python.org/dev/peps/pep-0227/ Implementation XXX Jeremy, is this still the case? The implementation for C Python uses flat closures [1]. In case you might care about a user confusion ... Your reply left me puzzled that PEPs that have reached the standards track would not be considered part of the CPython documentation distribution. Thank you, Alan Isaac -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11023 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)
Steven Bethard steven.beth...@gmail.com added the comment: Done in r88268. Thanks again everyone! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10680 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11071] What's New review comments
Nick Coghlan ncogh...@gmail.com added the comment: Another significant logging change: the addition of the style parameter for Formatter objects (allowing the use of str.format and string.Template style substitution instead of percent formatting) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11071] What's New review comments
Nick Coghlan ncogh...@gmail.com added the comment: The last two logging changes potentially worth mentioning that I noticed: - simple callables can now be supplied as logging filters (see the version 3.2 note in http://docs.python.org/dev/library/logging#filter-objects) - the logging API docs now include a section dedicated to the available attributes on LogRecord instances (http://docs.python.org/dev/library/logging#filter-objects). This makes it much easier to write Filter and Formatter objects that reference these attributes. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11071] What's New review comments
Nick Coghlan ncogh...@gmail.com added the comment: I was wrong, I found one more potentially notable logging change: http://docs.python.org/dev/library/logging#logging.setLogRecordFactory -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11071] What's New review comments
Nick Coghlan ncogh...@gmail.com added the comment: Adding Vinay, given the number of logging changes in 3.2 that don't appear to be in the What's New yet (the only logging change noted there at the moment is the inclusion of PEP 391) -- nosy: +vinay.sajip ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11068] Python 2.7.1 Idle traceback on OS X (10.6.6)
David Meier djme...@gmail.com added the comment: Removing the 10.6 specific Python 2.7.1 installation (with the instructions provided by Ned) and reinstalling the 10.3-10.6 32bit installation fixed the aforementioned segfault. Thanks for the information, however, I do think it should be noted on the download page that there are problems with the 10.6 32/64-bit version and it is safer to go the 32-bit only installer unless there is a specific need. I did not see any caveats mentioned when I went to download it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9527] Add aware local time support to datetime module
Changes by Miki Tebeka miki.teb...@gmail.com: -- nosy: -tebeka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11048] import ctypes causes segfault on read-only filesystem
Marcin Bachry hegel...@gmail.com added the comment: This patch fixes issue with unitialized variable which makes ctypes crash in error handler. Note that for you it merely turns Segmentation fault into MemoryError exception. Python ships with buggy version of libffi, which tries to allocate memory using mmap() over a temporary file (the one seen in strace output above) instead of just doing mmap(MAP_ANONYMOUS|MAP_PRIVATE). The bug is fixed in this libffi commit: https://github.com/atgreen/libffi/commit/eaf444eabc4c78703c0f98ac0197b1619c1b1bef Until Python's libffi is updated, you can do mount -t tmpfs none /dev/shm. It's good to have tmpfs mounted anyway, just like proc and sysfs. -- keywords: +patch nosy: +marcin.bachry Added file: http://bugs.python.org/file20619/ctypes-erofs-crash.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11048 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11059] Mercurial fails on code.python.org repo
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: 'Had to look on a sunday once again, and it is still impossible to clone branches/release2.7-maint. In the meanwhile the Mercurial people from http://mercurial.selenic.com reacted - they play the ball back to python.org. *However*: there are a lot of Issues at http://mercurial.selenic.com/bts/issueXY (try 2606, 2602, 2595, my 2239 and possibly others). -- status: closed - open title: code.python.org repo failures introduced! - Mercurial fails on code.python.org repo versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11059 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10716] Modernize pydoc to use CSS
Ron Adam ron_a...@users.sourceforge.net added the comment: A reminder: Check for instances where html.escape is not called on data inserted into the html pages. I'll update the patch as the non-css (error handling) parts made it into python 3.2. :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10716 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11059] Mercurial fails on code.python.org repo
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: http://mercurial.selenic.com/bts/issue2595 says code.python.org/hg often seems unstable., so it seems to be a well known thing. I leave this issue now open nevertheless, and let some experienced Python.org user decide what to do with it. (Antoine Pitrou, you are nosy, and it seems i have completely missed your hint (Works fine here did not count for me) - will you close that as approbiate?) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11059 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11059] Mercurial fails on code.python.org repo
Antoine Pitrou pit...@free.fr added the comment: 'Had to look on a sunday once again, and it is still impossible to clone branches/release2.7-maint. It failed here on one attempt and succeeded on others. hg verify ran fine too, including on the server. I'm closing the issue again; in all likelihood, this is either a transient network issue, or a Mercurial bug - and certainly not a bug in Python itself which is what this tracker is for ;) -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11059 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11048] import ctypes causes segfault on read-only filesystem
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: It would be nice to add a unit test to this patch. I don't think messing with read-only filesystems is feasible in regrtest, but it seems from reading _ctypes_alloc_callback() source that similar behavior can be triggered by passing a failing converters list to a ctypes function constructor. A nit-pick: it would be easier to verify that all CThunkObject fields are initialized if initialization was done in the same order as declaration: typedef struct { PyObject_VAR_HEAD ... PyObject *callable; PyObject *restype; SETFUNC setfunc; ffi_type *ffi_restype; ffi_type *atypes[1]; } CThunkObject; In other words, p-restype = NULL; should go after p-callable = NULL;. -- nosy: +belopolsky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11048 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11071] What's New review comments
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: Nick, thanks for the read-through and comments. Later this week, will get add a section of logging. Other people are also welcome to use this tracker item for other comments. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11071 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6715] xz compressor support
Changes by devurandom devuran...@gmx.net: -- nosy: -devurandom ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6715 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7502] All DocTestCase instances compare and hash equal to each other
Changes by Antoine Pitrou pit...@free.fr: -- stage: needs patch - patch review versions: +Python 3.3 -Python 2.6, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7502 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11069] IDLE crashes when Stack Viewer opened
Brian Curtin cur...@acm.org added the comment: Fixed in release31-maint in r88269. -- stage: - committed/rejected ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11069 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10990] tests mutating sys.gettrace() w/o re-instating previous state
Changes by Brett Cannon br...@python.org: Removed file: http://bugs.python.org/file20581/issue10990.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10990 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10990] tests mutating sys.gettrace() w/o re-instating previous state
Brett Cannon br...@python.org added the comment: Sorry about that. New patch attached. -- Added file: http://bugs.python.org/file20620/issue_10990.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10990 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9931] test_ttk_guionly hangs on XP5
Paul Moore p.f.mo...@gmail.com added the comment: Patch looks good to me. Can this be applied? As a temporary workaround I have set my buildbot to run interactively. Once the fix is applied, I will switch back to running as a service. -- keywords: +buildbot ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9931 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com