Re: what gui designer is everyone using
On Fri, Jun 8, 2012 at 7:18 AM, Kevin Walzer wrote: > On 6/5/12 10:10 AM, Mark R Rivet wrote: >> >> I want a gui designer that writes the gui code for me. I don't want to >> write gui code. what is the gui designer that is most popular? >> I tried boa-constructor, and it works, but I am concerned about how >> dated it seems to be with no updates in over six years. > > > None. I write GUI code by hand (Tkinter). I don't often build GUIs in Python, but all my GUI code these days is hand-built. The last builder I used would probably have been VX-REXX on OS/2, which doesn't help you much :) But my GTK code has always been hand-made. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python libraries portable?
On Thu, 07 Jun 2012 20:20:47 +, jkells wrote: > We are new to developing applications with Python. A question came up > concerning Python libraries being portable between Architectures. > More specifically, can we take a python library that runs on a X86 > architecture and run it on a SPARC architecture or do we need to get the > native libraries for SPARC? > > Thanking you in advance That would depend on the particular module if it is a pure python module then it will work anywhere if it is a C module for example cStringIO then it would be architecture dependent. some modules are wrappers to external library's (example GTK) so for those to work the necessary library files would need to be available if you are using modules that are in the standard library (except some platform specific ones ) then they should be available across all platforms, otherwise you would need to check see http://docs.python/library for details of the standard library -- http://mail.python.org/mailman/listinfo/python-list
Re: what gui designer is everyone using
On Thu, 07 Jun 2012 20:58:09 -0700, CM wrote: > On Jun 5, 10:10 am, Mark R Rivet wrote: >> I want a gui designer that writes the gui code for me. I don't want to >> write gui code. what is the gui designer that is most popular? >> I tried boa-constructor, and it works, but I am concerned about how >> dated it seems to be with no updates in over six years. > > Boa Constructor. Very happy with it. Mostly use it for the IDE these > days, as it already served to help build the GUI. I am using glade at present but I am still in the process of learning -- http://mail.python.org/mailman/listinfo/python-list
Re: what gui designer is everyone using
I used wx and Boa years before and Was quite pleased. In these days I switched to Qt with PySide. Qt designer works quite well. If you have the choice, then my recommendation is this. Cheers - chris Sent from my Ei4Steve On Jun 8, 2012, at 8:11, Alister wrote: > On Thu, 07 Jun 2012 20:58:09 -0700, CM wrote: > >> On Jun 5, 10:10 am, Mark R Rivet wrote: >>> I want a gui designer that writes the gui code for me. I don't want to >>> write gui code. what is the gui designer that is most popular? >>> I tried boa-constructor, and it works, but I am concerned about how >>> dated it seems to be with no updates in over six years. >> >> Boa Constructor. Very happy with it. Mostly use it for the IDE these >> days, as it already served to help build the GUI. > > I am using glade at present but I am still in the process of learning > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: what gui designer is everyone using
Hi Miki, Yes, and this works very well. As a side effect it also serves as a template when you need to change certain things dynamically. You can pick snippets for your Gui dynamication. But as a strong recommendation: never ever change the generated code. Import the generated classes and derive your own on top of it. I even prefer not to derive, but to delegate, to keep my name space tidy. Cheers - chris Sent from my Ei4Steve On Jun 7, 2012, at 21:05, Miki Tebeka wrote: >> what is the gui designer that is most popular? > IIRC Qt designer can output Python code. > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Order a list to get a hierarchical order
Hi, Having a list of objet with a parent_id attribute pointing to a parent, I want to order this list like this : [Parent #1, Child #1.1, Child#1.1.1, Child#1.1.2, Child#1.2, Parent #2, Child #2.1, ...] Any clue on how to do this ? Thanks, -- http://mail.python.org/mailman/listinfo/python-list
Re: Order a list to get a hierarchical order
Something like this? #!/usr/bin/env python3 import random class Node: def __init__(self, parent, name): self.parent, self.name = parent, name def __repr__(self): return self.name p_1 = Node(None, 'Parent #1') p_2 = Node(None, 'Parent #2') c_1_1 = Node(p_1, 'Child #1.1') c_1_1_1 = Node(c_1_1, 'Child #1.1.1') c_1_1_2 = Node(c_1_1, 'Child #1.1.2') c_1_2 = Node(p_1, 'Child #1.2') c_2_1 = Node(p_2, 'Child #2.1') node_list = [p_1, p_2, c_1_1, c_1_1_1, c_1_1_2, c_1_2, c_2_1] random.shuffle(node_list) print(node_list) def append_node(n, l, ls): ls.append(n) for c in [nc for nc in l if nc.parent is n]: append_node(c, l, ls) return ls def sort_nodes(l): ls = [] for r in l: if r.parent == None: append_node(r, l, ls) return ls print(sort_nodes(node_list)) On Fri, Jun 8, 2012 at 11:10 AM, Thibaut DIRLIK wrote: > Hi, > > Having a list of objet with a parent_id attribute pointing to a parent, I > want to order this list like this : > > [Parent #1, Child #1.1, Child#1.1.1, Child#1.1.2, Child#1.2, Parent #2, > Child #2.1, ...] > > Any clue on how to do this ? > > Thanks, > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Order a list to get a hierarchical order
Ivars Geidans wrote: > Something like this? Or this (I'm reusing some of your code but let the built-in sorted() do the hard work): #!/usr/bin/env python3 import random def _reverse_iterpath(node): while node is not None: yield node.name node = node.parent def path(node): return tuple(_reverse_iterpath(node))[::-1] class Node: def __init__(self, parent, name): self.parent = parent self.name = name def __repr__(self): return "/".join(path(self)) def show(caption, node_list): print(caption.center(len(caption)+10, "-")) for node in node_list: print(node) print() if __name__ == "__main__": p_1 = Node(None, 'Parent #1') p_2 = Node(None, 'Parent #2') c_1_1 = Node(p_1, 'Child #1.1') c_1_1_1 = Node(c_1_1, 'Child #1.1.1') c_1_1_2 = Node(c_1_1, 'Child #1.1.2') c_1_2 = Node(p_1, 'Child #1.2') c_2_1 = Node(p_2, 'Child #2.1') node_list = [p_1, p_2, c_1_1, c_1_1_1, c_1_1_2, c_1_2, c_2_1] random.shuffle(node_list) show("before", node_list) show("after", sorted(node_list, key=path)) -- http://mail.python.org/mailman/listinfo/python-list
Re: Order a list to get a hierarchical order
Ivars Geidans wrote: > def append_node(n, l, ls): > ls.append(n) > for c in [nc for nc in l if nc.parent is n]: > append_node(c, l, ls) > return ls > > def sort_nodes(l): > ls = [] > for r in l: > if r.parent == None: > append_node(r, l, ls) > > return ls This ensures that child nodes appear after their parent but leaves the order of nodes on the same level undefined. I think adding def sort_nodes(l): l = sorted(l, key=lambda node: node.name) #untested ... would fix that. -- http://mail.python.org/mailman/listinfo/python-list
what gui designer is everyone using
Hi, pyQt is really good for fast graphic GUI designing. Maybe not the best for beginners,cause this can't allow them to understand how to code GUIs. And as said before, for each modification not need to regenerate the code,it's sometimes boring Loïc > From: tis...@stackless.com > Subject: Re: what gui designer is everyone using > Date: Fri, 8 Jun 2012 11:27:44 +0200 > To: miki.teb...@gmail.com > CC: python-list@python.org > > Hi Miki, > > Yes, and this works very well. As a side > effect it also serves as a template when > you need to change certain things > dynamically. You can pick snippets for > your Gui dynamication. > > But as a strong recommendation: never > ever change the generated code. Import the generated classes and derive > your own on top of it. > I even prefer not to derive, but to delegate, to keep my name space tidy. > > Cheers - chris > > Sent from my Ei4Steve > > On Jun 7, 2012, at 21:05, Miki Tebeka wrote: > > >> what is the gui designer that is most popular? > > IIRC Qt designer can output Python code. > > -- > > http://mail.python.org/mailman/listinfo/python-list > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)
> I want a gui designer that writes the gui code for me. I don't want to > write gui code. what is the gui designer that is most popular? > I tried boa-constructor, and it works, but I am concerned about how > dated it seems to be with no updates in over six years. Sorry to "hijack" your thread, but since this is a very related question... What "GUI designer" would come the closest to the way that Cocoa's Interface Builder works? I.e. is there any one (cross-platform) that allows to actually "connect" the GUI created directly to the code and make it available "live" in an IDE? This whole cycle of "design GUI"->"generate code"->add own code to generated code"->"run application with GUI" has always seemed very un-pythonic to me. A dynamic, interpreted language should allow to work in a more "lively", "direct" way to build a GUI. TIA, Sincerely, Wolfgang -- http://mail.python.org/mailman/listinfo/python-list
Re: Order a list to get a hierarchical order
Thanks for your help, I'll test this. 2012/6/8 Peter Otten <__pete...@web.de> > Ivars Geidans wrote: > > > def append_node(n, l, ls): > > ls.append(n) > > for c in [nc for nc in l if nc.parent is n]: > > append_node(c, l, ls) > > return ls > > > > def sort_nodes(l): > > ls = [] > > for r in l: > > if r.parent == None: > > append_node(r, l, ls) > > > > return ls > > This ensures that child nodes appear after their parent but leaves the > order > of nodes on the same level undefined. I think adding > > def sort_nodes(l): > l = sorted(l, key=lambda node: node.name) #untested > ... > > would fix that. > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python libraries portable?
On 6/8/2012 4:09 AM, Alister wrote: On Thu, 07 Jun 2012 20:20:47 +, jkells wrote: We are new to developing applications with Python. A question came up concerning Python libraries being portable between Architectures. More specifically, can we take a python library that runs on a X86 architecture and run it on a SPARC architecture or do we need to get the native libraries for SPARC? Thanking you in advance That would depend on the particular module if it is a pure python module then it will work anywhere Unless it uses one of the few things that are system dependent. But these are marked in the docs (example: "Abailability: Unix") and are mostly in the os module. An example is os.fork. There are also some system-specific things in the socket module, although it embodies much effort to make things as cross-platform as possible. if it is a C module for example cStringIO then it would be architecture dependent. some modules are wrappers to external library's (example GTK) so for those to work the necessary library files would need to be available if you are using modules that are in the standard library (except some platform specific ones ) then they should be available across all platforms, otherwise you would need to check see http://docs.python/library for details of the standard library -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
what gui designer is everyone using
Hi, pyQt is really good for fast graphic GUI design. Maybe not the best for beginners,cause this can't allow them to understand how to code GUIs. And as said before, for each modification you need to regenerate the code,it's sometimes boring. (sorry) Loïc From: laureote-l...@hotmail.fr To: python-list@python.org Subject: what gui designer is everyone using Date: Fri, 8 Jun 2012 14:22:58 +0200 Hi, pyQt is really good for fast graphic GUI designing. Maybe not the best for beginners,cause this can't allow them to understand how to code GUIs. And as said before, for each modification not need to regenerate the code,it's sometimes boring Loïc > From: tis...@stackless.com > Subject: Re: what gui designer is everyone using > Date: Fri, 8 Jun 2012 11:27:44 +0200 > To: miki.teb...@gmail.com > CC: python-list@python.org > > Hi Miki, > > Yes, and this works very well. As a side > effect it also serves as a template when > you need to change certain things > dynamically. You can pick snippets for > your Gui dynamication. > > But as a strong recommendation: never > ever change the generated code. Import the generated classes and derive > your own on top of it. > I even prefer not to derive, but to delegate, to keep my name space tidy. > > Cheers - chris > > Sent from my Ei4Steve > > On Jun 7, 2012, at 21:05, Miki Tebeka wrote: > > >> what is the gui designer that is most popular? > > IIRC Qt designer can output Python code. > > -- > > http://mail.python.org/mailman/listinfo/python-list > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)
On Jun 8, 8:27 am, Wolfgang Keller wrote: > > I want a gui designer that writes the gui code for me. I don't want to > > write gui code. what is the gui designer that is most popular? > > I tried boa-constructor, and it works, but I am concerned about how > > dated it seems to be with no updates in over six years. > > Sorry to "hijack" your thread, but since this is a very related > question... > > What "GUI designer" would come the closest to the way that Cocoa's > Interface Builder works? I.e. is there any one (cross-platform) that > allows to actually "connect" the GUI created directly to the code and > make it available "live" in an IDE? > > This whole cycle of "design GUI"->"generate code"->add own code to > generated code"->"run application with GUI" has always seemed very > un-pythonic to me. A dynamic, interpreted language should allow to work > in a more "lively", "direct" way to build a GUI. > > TIA, > > Sincerely, > > Wolfgang I'm curious about your point but I don't really understand it. Could you try again without using any scare-quoted words? Maybe given an example of creating a small text editor application with a GUI builder/ IDE in this Pythonic way you are hoping for. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does this leak memory?
"John Gordon" wrote in message news:jqr3v5$src$1...@reader1.panix.com... I'm unfamiliar with gc output, but just glancing over it I don't see anything that looks like a leak. It reported that there were 19 objects which are unreachable and therefore are candidates for being collected. What makes you think there is a leak? Well, I guess I was confused by the terminology. I thought there were leaked objects _after_ a garbage collection had been run (as it said "collecting generation 2"). Also, "unreachable" actually appears to mean "unreferenced". You live n learn... Cheers. -- http://mail.python.org/mailman/listinfo/python-list
About a list comprehension to transform an input list
>From a sequence of numbers, I'm trying to get a list that does something to >even numbers but leaves untouched the odd ones, say: [0,1,2,3,4,...] ==> [100,1,102,3,104,...] I know that this can be done with an auxiliary function, as follows: ->>> def filter(n): ... if (n%2 == 0): ... return 100+n ... return n ... ->>> L = range(10) ->>> [filter(n) for n in L] [100, 1, 102, 3, 104, 5, 106, 7, 108, 9] I wonder whether there can be a single list comprehension expression to get this result without the aid of the auxiliary function. Do you have any comments on this? Thanks, --Sergio. -- http://mail.python.org/mailman/listinfo/python-list
Re: About a list comprehension to transform an input list
On Fri, Jun 8, 2012 at 6:10 PM, Julio Sergio wrote: > >From a sequence of numbers, I'm trying to get a list that does something to > >even > numbers but leaves untouched the odd ones, say: > > [0,1,2,3,4,...] ==> [100,1,102,3,104,...] > > I know that this can be done with an auxiliary function, as follows: > > ->>> def filter(n): > ... if (n%2 == 0): > ... return 100+n > ... return n > ... > ->>> L = range(10) > ->>> [filter(n) for n in L] > [100, 1, 102, 3, 104, 5, 106, 7, 108, 9] > > I wonder whether there can be a single list comprehension expression to get > this > result without the aid of the auxiliary function. > > Do you have any comments on this? >>> l = [0,1,2,3,4,5,6,7,8,9] >>> [n if n%2 else 100+n for n in l] [100, 1, 102, 3, 104, 5, 106, 7, 108, 9] Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: About a list comprehension to transform an input list
On 6/8/2012 9:17 AM Daniel Urban said... On Fri, Jun 8, 2012 at 6:10 PM, Julio Sergio wrote: > From a sequence of numbers, I'm trying to get a list that does something to even numbers but leaves untouched the odd ones, say: [0,1,2,3,4,...] ==> [100,1,102,3,104,...] I know that this can be done with an auxiliary function, as follows: ->>> def filter(n): ... if (n%2 == 0): ... return 100+n ... return n ... ->>> L = range(10) ->>> [filter(n) for n in L] [100, 1, 102, 3, 104, 5, 106, 7, 108, 9] I wonder whether there can be a single list comprehension expression to get this result without the aid of the auxiliary function. Do you have any comments on this? l = [0,1,2,3,4,5,6,7,8,9] [n if n%2 else 100+n for n in l] [100, 1, 102, 3, 104, 5, 106, 7, 108, 9] Or alternately by leveraging true/false as 1/0: >>> [ 100*(not(ii%2))+ii for ii in range(10)] [100, 1, 102, 3, 104, 5, 106, 7, 108, 9] >>> [ 100*(ii%2)+ii for ii in range(10)] [0, 101, 2, 103, 4, 105, 6, 107, 8, 109] -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does this leak memory?
On Fri, Jun 8, 2012 at 10:02 AM, Steve wrote: > Well, I guess I was confused by the terminology. I thought there were leaked > objects _after_ a garbage collection had been run (as it said "collecting > generation 2"). That means that it's going to check all objects. The garbage collector divides the objects up into "generations", based on how many collection attempts they've so far survived (due to not being unreachable). For efficiency, higher generation objects are checked less frequently than lower generation objects, and generation 2 is the highest. > Also, "unreachable" actually appears to mean "unreferenced". Not exactly. CPython uses reference counting as well as periodic garbage collection, so an unreferenced object is deallocated immediately. "Unreachable" means that the object is referenced but cannot be reached via direct or indirect reference from any stack frame -- i.e., the object is only referenced in unreachable reference cycles. -- http://mail.python.org/mailman/listinfo/python-list
Re: About a list comprehension to transform an input list
On Fri, Jun 8, 2012 at 10:43 AM, Emile van Sebille wrote: > Or alternately by leveraging true/false as 1/0: > [ 100*(not(ii%2))+ii for ii in range(10)] The same thing, leaving bools out of it altogether: >>> [100*(1-ii%2)+ii for ii in range(10)] -- http://mail.python.org/mailman/listinfo/python-list
RE: Installing MySQLdb via FTP?
> Is it possible to install MySQLdb via FTP? > > 1)I have a hostmonster account with SSH. I have been able to log in > and install MySQLdb from the shell. Works fine. > > 2)Now I have a client who wants to have a hostmonster account and we > will need MySQLdb. I *will not* have SSH access since (as I > understand it) hostmonster allows SSH access from 1 IP only. > > 3)The hostmonster account services (I.E. cpanel) does not have any > service to do this. > > 4)I wouldn't need to make the install on PYTHONPATH as my resources > will handle sys.path configuration. > > This isn't an immediate need so URLs and pointers to relevant > discussions would suffice. Why not just write a script that will install it for them and then give them a copy of that script? Alternatively, have the client contact hostmonster and have them install it; I imagine a decent webhost would be able to do this manually if asked via email/ticket. I would imagine that if you know where all the files go, it would be possible copy all the files over FTP and have it work. Granted, I am not familiar with installing this package so I could be wrong. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
RE: Where is the lastest step by step guide to compile Python into an executable?
> > Where is the lastest step by step guide to compile Python into an > executable? > > > > Regards. > > > > David > > > > > > > > > > Google. I think you mean the Internet as Google is just an index. Unless you are referring to Google's cache. :) Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing MySQLdb via FTP?
* Prasad, Ramit [120608 09:38]: > > Is it possible to install MySQLdb via FTP? > > > > 1)I have a hostmonster account with SSH. I have been able to log in > > and install MySQLdb from the shell. Works fine. > > > > 2)Now I have a client who wants to have a hostmonster account and we > > will need MySQLdb. I *will not* have SSH access since (as I > > understand it) hostmonster allows SSH access from 1 IP only. > > > > 3)The hostmonster account services (I.E. cpanel) does not have any > > service to do this. > > > > 4)I wouldn't need to make the install on PYTHONPATH as my resources > > will handle sys.path configuration. > > > > This isn't an immediate need so URLs and pointers to relevant > > discussions would suffice. > > Why not just write a script that will install it for them and then > give them a copy of that script? Alternatively, have the client > contact hostmonster and have them install it; I imagine a decent > webhost would be able to do this manually if asked via email/ticket. No they would not. In fact, the hoster that I am trying to get my client away from won't either. It would be great to find a dependable hoster that *would* do manually installs, but most seem to be a one-size fits all. > I would imagine that if you know where all the files go, it would > be possible copy all the files over FTP and have it work. Granted, > I am not familiar with installing this package so I could be wrong. See the thread titled "Python libraries portable?" you will note that Corey Richardson makes the statement that MySQLdb is a C extension. I accepted that statement, but upon looking at the directories (I am on Mac Lion, but believe it may be the same for Linux) I see no binaries, just straight .py and .pyc files. *However* as it often turns out, I was barking up the wrong tree. A very nice gentleman (I presume) emailed me privately to say (I'm sure to save me the public embarassment because I should have though of it myself) "Ssh to your client and from the client ssh hostmonster" and therein is the solution. I guess I would have thought of it in the next few days whilst visiting the little boys room or mowing the lawn, but Kudos to Rod Person for his solution. -- Tim tim at tee jay forty nine dot com or akwebsoft dot com http://www.akwebsoft.com -- http://mail.python.org/mailman/listinfo/python-list
RunPy (was py2bat (was: How do I make a Python .bat executable file?))
no way just use py2exe 1.download it and python 2.make a setup file with this replacing ? with python file name: from setuptools import setup setup(app=['Tic-Tac-Toe easy.py']) james a intermediate child programmer -- http://mail.python.org/mailman/listinfo/python-list
mode for file created by open
If a new file is created by open ('xxx', 'w') How can I control the file permission bits? Is my only choice to use chmod after opening, or use os.open? Wouldn't this be a good thing to have as a keyword for open? Too bad what python calls 'mode' is like what posix open calls 'flags', and what posix open calls 'mode' is what should go to chmod. -- http://mail.python.org/mailman/listinfo/python-list
Re: mode for file created by open
On Fri, Jun 8, 2012 at 2:36 PM, Neal Becker wrote: > If a new file is created by open ('xxx', 'w') > > How can I control the file permission bits? Is my only choice to use chmod > after opening, or use os.open? For whatever it's worth, in Python 3.3 you have the additional option of providing a special file opener. http://docs.python.org/dev/library/functions.html#open -- Devin -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing MySQLdb via FTP?
On Fri, 8 Jun 2012 09:55:23 -0800 Tim Johnson wrote: > See the thread titled "Python libraries portable?" you will note > that Corey Richardson makes the statement that MySQLdb is a C > extension. I accepted that statement, but upon looking at the > directories (I am on Mac Lion, but believe it may be the same for > Linux) I see no binaries, just straight .py and .pyc files. > http://mysql-python.hg.sourceforge.net/hgweb/mysql-python/MySQLdb-2.0/file/566baac88764/src It definitely is. The C extension part is the '_mysql' module, here it is /usr/lib64/python2.7/site-packages/_mysql.so. MySQLdb (of which _mysql is a part) uses that to provide a DB-API 2.0 compliant API. > *However* as it often turns out, I was barking up the wrong tree. > (I haven't followed this thread at all besides noticing this message) -- Corey Richardson -- http://mail.python.org/mailman/listinfo/python-list
Import semantics?
Did the import semantics change in cpython 3.3a4? I used to be able to import treap.py even though I had a treap directory in my cwd. With 3.3a4, I have to rename the treap directory to see treap.py. -- http://mail.python.org/mailman/listinfo/python-list
Re: Import semantics?
Dan Stromberg wrote: Did the import semantics change in cpython 3.3a4? I used to be able to import treap.py even though I had a treap directory in my cwd. With 3.3a4, I have to rename the treap directory to see treap.py. Check out PEP 420 -- Implicit Namespace Packages [http://www.python.org/dev/peps/pep-0420/] ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Import semantics?
On Fri, Jun 8, 2012 at 3:16 PM, Ethan Furman wrote: > Dan Stromberg wrote: > >> >> Did the import semantics change in cpython 3.3a4? >> >> I used to be able to import treap.py even though I had a treap directory >> in my cwd. With 3.3a4, I have to rename the treap directory to see >> treap.py. >> > > Check out PEP 420 -- Implicit Namespace Packages [ > http://www.python.org/dev/peps/pep-0420/] > Am I misinterpreting this? It seems like according to the PEP, I should have still been able to import treap.py despite having a treap/. But I couldn't; I had to rename treap/ to treap-dir/ first. During import processing, the import machinery will continue to iterate over each directory in the parent path as it does in Python 3.2. While looking for a module or package named "foo", for each directory in the parent path: - If /foo/__init__.py is found, a regular package is imported and returned. - If not, but /foo.{py,pyc,so,pyd} is found, a module is imported and returned. The exact list of extension varies by platform and whether the -O flag is specified. The list here is representative. - If not, but /foo is found and is a directory, it is recorded and the scan continues with the next directory in the parent path. - Otherwise the scan continues with the next directory in the parent path. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Import semantics?
On Fri, Jun 8, 2012 at 4:24 PM, Dan Stromberg wrote: > Am I misinterpreting this? It seems like according to the PEP, I should > have still been able to import treap.py despite having a treap/. But I > couldn't; I had to rename treap/ to treap-dir/ first. That's how I understand it. The existence of a module or regular package 'foo' anywhere in the path should trump the creation of a 'foo' namespace package, even if the namespace package would be earlier in the path. Ar you sure you don't have an __init__.py in your treap directory? -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-Dev] Import semantics?
Eric V. Smith wrote: On 6/8/2012 6:41 PM, Ethan Furman wrote: Dan Stromberg wrote: On Fri, Jun 8, 2012 at 3:16 PM, Ethan Furman wrote: Dan Stromberg wrote: Did the import semantics change in cpython 3.3a4? I used to be able to import treap.py even though I had a treap directory in my cwd. With 3.3a4, I have to rename the treap directory to see treap.py. Check out PEP 420 -- Implicit Namespace Packages [http://www.python.org/dev/peps/pep-0420/] Am I misinterpreting this? It seems like according to the PEP, I should have still been able to import treap.py despite having a treap/. But I couldn't; I had to rename treap/ to treap-dir/ first. During import processing, the import machinery will continue to iterate over each directory in the parent path as it does in Python 3.2. While looking for a module or package named "foo", for each directory in the parent path: * If /foo/__init__.py is found, a regular package is imported and returned. * If not, but /foo.{py,pyc,so,pyd} is found, a module is imported and returned. The exact list of extension varies by platform and whether the -O flag is specified. The list here is representative. * If not, but /foo is found and is a directory, it is recorded and the scan continues with the next directory in the parent path. * Otherwise the scan continues with the next directory in the parent path. I do not understand PEP 420 well enough to say if this is intentional or a bug -- thoughts? I missed the beginning of this discussion and I need some more details. What directories are on sys.path, where do treap.py and treap/ appear in them, and is there an __init__.py in treap? At first blush it sounds like it should continue working. If you (Dan?) could re-create this in a small example and open a bug, that would be great. Eric. -- http://mail.python.org/mailman/listinfo/python-list
Re: Import semantics?
On Fri, Jun 8, 2012 at 6:24 PM, Dan Stromberg wrote: > Am I misinterpreting this? It seems like according to the PEP, I should > have still been able to import treap.py despite having a treap/. But I > couldn't; I had to rename treap/ to treap-dir/ first. Only if treap/ and treap.py were in the same directory. Otherwise it looks like whichever comes first in the search path is imported first. -- Devin -- http://mail.python.org/mailman/listinfo/python-list
Re: mode for file created by open
On 08Jun2012 14:36, Neal Becker wrote: | If a new file is created by open ('xxx', 'w') | | How can I control the file permission bits? Is my only choice to use chmod | after opening, or use os.open? | | Wouldn't this be a good thing to have as a keyword for open? Too bad what | python calls 'mode' is like what posix open calls 'flags', and what posix open | calls 'mode' is what should go to chmod. Well, it does honour the umask, and will call the OS open with 0666 mode so you'll get 0666-umask mode bits in the new file (if it is new). Last time I called os.open was to pass a mode of 0 (raceproof lockfile). I would advocate (untested): fd = os.open(...) os.fchmod(fd, new_mode) fp = os.fdopen(fd) If you need to constrain access in a raceless fashion (specificly, no ealy window of _extra_ access) pass a restrictive mode to os.open and open it up with fchmod. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ It was a joke, OK? If we thought it would actually be used, we wouldn't have written it! - Marc Andreessen on the creation of a tag -- http://mail.python.org/mailman/listinfo/python-list
Passing ints to a function
Hello, I want to pass several values to a function which is located on a server (so I can't change its behavior). That function only accepts five values which must be ints. There are several lists: a = [1, 2, 3, 4, 5] b = [5, 4, 3, 2, 1] c = [0, 0, 0, 0, 0] I want to pass each value from these lists to that function. What is the most pythonic way? This wouldn't work because we're passing a list not ints: function(a) function(b) function(c) This wouldn't work too (the reason is the same): def foo(x): return x[0], x[1], x[2], x[3], x[4], x[5] function(foo(a)) function(foo(b)) function(foo(c)) This would work, but it's not pythonic at all (imagine that you want to call it 10 times or even more). function(a[0], a[1], a[2], a[3], a[4], a[5]) function(b[0], b[1], b[2], b[3], b[4], b[5]) function(c[0], c[1], c[2], c[3], c[4], c[5]) Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing ints to a function
On Fri, Jun 8, 2012 at 5:41 PM, stayvoid wrote: > Hello, > > I want to pass several values to a function which is located on a > server (so I can't change its behavior). > That function only accepts five values which must be ints. > > There are several lists: > a = [1, 2, 3, 4, 5] > b = [5, 4, 3, 2, 1] > c = [0, 0, 0, 0, 0] > > I want to pass each value from these lists to that function. > What is the most pythonic way? function(*a) Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing ints to a function
On Fri, Jun 8, 2012 at 7:41 PM, stayvoid wrote: > Hello, > > I want to pass several values to a function which is located on a > server (so I can't change its behavior). > That function only accepts five values which must be ints. > > There are several lists: > a = [1, 2, 3, 4, 5] > b = [5, 4, 3, 2, 1] > c = [0, 0, 0, 0, 0] > > I want to pass each value from these lists to that function. > What is the most pythonic way? > function(*a) * expands a list into positional arguments and ** expands a dictionary into keyword arguments. -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing ints to a function
On Fri, 08 Jun 2012 16:41:40 -0700, stayvoid wrote: > Hello, > > I want to pass several values to a function which is located on a server > (so I can't change its behavior). That function only accepts five values > which must be ints. > > There are several lists: > a = [1, 2, 3, 4, 5] > b = [5, 4, 3, 2, 1] > c = [0, 0, 0, 0, 0] > > I want to pass each value from these lists to that function. What is the > most pythonic way? You want to unpack the list: function(*a) # like function(a[0], a[1], a[2], ...) If you have many lists, use a for-loop: for L in (a, b, c): function(*L) -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Import semantics?
On Fri, Jun 8, 2012 at 3:48 PM, Ian Kelly wrote: > On Fri, Jun 8, 2012 at 4:24 PM, Dan Stromberg wrote: > > Am I misinterpreting this? It seems like according to the PEP, I should > > have still been able to import treap.py despite having a treap/. But I > > couldn't; I had to rename treap/ to treap-dir/ first. > > That's how I understand it. The existence of a module or regular > package 'foo' anywhere in the path should trump the creation of a > 'foo' namespace package, even if the namespace package would be > earlier in the path. Ar you sure you don't have an __init__.py in > your treap directory? > The issue replicated in a minimal way (it's in the ticket too): dstromberg@zareason-limbo6000a /tmp/tt $ mv treap treap-dir dstromberg@zareason-limbo6000a /tmp/tt $ /usr/local/cpython-3.3/bin/python -c 'import sys; print(sys.path); import treap; t = treap.treap()' ['', '/usr/local/cpython-3.3/lib/python33.zip', '/usr/local/cpython-3.3/lib/python3.3', '/usr/local/cpython-3.3/lib/python3.3/plat-linux', '/usr/local/cpython-3.3/lib/python3.3/lib-dynload', '/usr/local/cpython-3.3/lib/python3.3/site-packages'] dstromberg@zareason-limbo6000a /tmp/tt $ mv treap-dir/ treap dstromberg@zareason-limbo6000a /tmp/tt $ /usr/local/cpython-3.3/bin/python -c 'import sys; print(sys.path); import treap; t = treap.treap()' ['', '/usr/local/cpython-3.3/lib/python33.zip', '/usr/local/cpython-3.3/lib/python3.3', '/usr/local/cpython-3.3/lib/python3.3/plat-linux', '/usr/local/cpython-3.3/lib/python3.3/lib-dynload', '/usr/local/cpython-3.3/lib/python3.3/site-packages'] Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'treap' dstromberg@zareason-limbo6000a /tmp/tt $ ls -l treap/__init__.py ls: cannot access treap/__init__.py: No such file or directory dstromberg@zareason-limbo6000a /tmp/tt $ /usr/local/cpython-3.3/bin/python Python 3.3.0a4 (default, Jun 8 2012, 14:14:41) [GCC 4.6.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing ints to a function
> You want to unpack the list: > > function(*a) # like function(a[0], a[1], a[2], ...) Awesome! I forgot about this. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Import semantics?
And a link to the ticket: http://bugs.python.org/issue15039 > -- http://mail.python.org/mailman/listinfo/python-list
Re: Some posts do not show up in Google Groups
On 4/30/2012 1:20 AM, Frank Millman wrote: Hi all For a while now I have been using Google Groups to read this group, but on the odd occasion when I want to post a message, I use Outlook Express, as I know that some people reject all messages from Google Groups due to the high spam ratio (which seems to have improved recently, BTW). From time to time I see a thread where the original post is missing, but the follow-ups do appear. My own posts have shown up with no problem. Now, in the last month, I have posted two messages using Outlook Express, and neither of them have shown up in Google Groups. I can see replies in OE, so they are being accepted. I send to the group gmane.comp.python.general. Does anyone know a reason for this, or have a solution? Frank Millman I can't answer your main question, but I have seen a reason for Google Groups appearing to have less spam. That was about the time Google Groups introduced a new interface which makes it obvious if anyone has already reported a message as spam (or any other type of abuse), and also made those messages inaccessible after two different users reported the same message as abuse. Therefore, many spammers are moving toward newsgroups where no one reports the spam. Robert Miles -- http://mail.python.org/mailman/listinfo/python-list
Re: Some posts do not show up in Google Groups
On 5/1/2012 1:12 AM, Frank Millman wrote: On Apr 30, 8:20 am, Frank Millman wrote: Hi all For a while now I have been using Google Groups to read this group, but on the odd occasion when I want to post a message, I use Outlook Express, as I know that some people reject all messages from Google Groups due to the high spam ratio (which seems to have improved recently, BTW). From time to time I see a thread where the original post is missing, but the follow-ups do appear. My own posts have shown up with no problem. Now, in the last month, I have posted two messages using Outlook Express, and neither of them have shown up in Google Groups. I can see replies in OE, so they are being accepted. I send to the group gmane.comp.python.general. Does anyone know a reason for this, or have a solution? Frank Millman Thanks for the replies. I am also coming to the conclusion that Google Groups is no longer fit-for-purpose. Ironically, here are two replies that I can see in Outlook Express, but do not appear in Google Groups. Reply from Benjamin Kaplan - I believe the mail-to-news gateway has trouble with HTML messages. Try sending everything as plain text and see if that works. I checked, and all my posts were sent in plain text. Reply from Terry Reedy - Read and post through news.gmane.org I have had a look at this before, but there is one thing that Google Groups does that no other reader seems to do, and that is that messages are sorted according to thread-activity, not original posting date. This makes it easy to see what has changed since the last time I checked. All the other ones I have looked at - Outlook Express, Thunderbird, and gmane.org, sort by original posting date, so I have to go backwards to see if any threads have had any new postings. Maybe there is a setting that I am not aware of. Can anyone enlighten me? Thanks Frank Thunderbird appears to change the sorting order for me based on whether I tell it to put the newest messages at the top of its window or at the bottom. Some newsgroups servers appear to discard every post they get that contains any HTML. This may be because Google Groups often adds HTML even if you don't ask for it, and those servers want to avoid the poor signal to noise ratio from Google Groups. Robert Miles -- http://mail.python.org/mailman/listinfo/python-list
Re: Where is the lastest step by step guide to compile Python into an executable?
On Sat, Jun 9, 2012 at 3:41 AM, Prasad, Ramit wrote: >> > Where is the lastest step by step guide to compile Python into an >> executable? >> >> Google. > > I think you mean the Internet as Google is just an index. > Unless you are referring to Google's cache. He means this: http://www.catb.org/~esr/faqs/smart-questions.html#rtfm ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Create directories and modify files with Python
On 5/1/2012 5:51 AM, deltaquat...@gmail.com wrote: Il giorno martedì 1 maggio 2012 01:57:12 UTC+2, Irmen de Jong ha scritto: [snip] Focus on file input and output, string manipulation, and look in the os module for stuff to help scanning directories (such as os.walk). Irmen Thanks for the directions. By the way, can you see my post in Google Groups? I'm not able to, and I don't know why. Sergio They may have copied the Gmail idea that you never need to see anything anything you posted yourself. When I post anything using Google Groups, my posts usually show but often very slowly - as in 5 minutes after I tell it to post. Robert Miles -- http://mail.python.org/mailman/listinfo/python-list