Re: when and how do you use Self?
As a point of style: the 'other' identifier should only be used in Zen Metaclass programming as an implicit reference to the calling object or as a list of references to all other instances of the class. Context will make it both clear and obvious which use case is desired. On 03/11/05, bruno at modulix <[EMAIL PROTECTED]> wrote: > Tieche Bruce A MSgt USMTM/AFD wrote: > > I am new to python, > > > > > > > > Could someone explain (in English) how and when to use self? > > > Don't use self. Use other. > -- > bruno desthuilliers > python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for > p in '[EMAIL PROTECTED]'.split('@')])" > -- > http://mail.python.org/mailman/listinfo/python-list > -- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython newbie question, creating "mega widgets" , and DnD
On 10 Nov 2005 07:19:30 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I've made the switch from tKinter to wxPython. I'm slowly trying to > learn it, but I had a question - what is the appropriate object to > subclass to create a "mega widget" ie A listbox with it's add/delete > buttons already built in? > > wxPanel seems a possibility - any thoughts? When I've created this type of thing I usually start with a wx.Panel. It will depend on how you plan to use your new mega-widget, but I suspect that the wx.Panel gives you the most flexibility. You can throw a panel pretty much anywhere and it seems to work just fine. :) PS: Congrats on giving wxPython a try. It's far from the perfect framework, but it seems the most Pythonic to me and lets me get the most accomplished with the least setup. YMMV. -- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does super() require the class as the first argument?
At runtime there is nothing to say that the class hasn't been subclassed again. example: class A(someclass): def __init__(self): super(self).__init__() do_something() class B(A): """No __init__""" def blah(self): pass When you use class B, how does the super we inheirited from A know where to call? Without the class name in super you end up with infinite recursion. (Which can be kinda fun to watch as it crashes...) Chris On Thu, 03 Feb 2005 12:05:27 -0800 (PST), Kevin Smith <[EMAIL PROTECTED]> wrote: > I like the idea of the super() function, but it doesn't seem to solve > the problem that I'm trying to fix. I don't like hard-coding in calls > to super classes using their names: > > class A(object): >def go(self): >... > > class B(A): >def go(self): >... >A.go(self) > > I don't like this because if I ever change the name of 'A', I have to go > through all of the methods and change the names there too. super() has > the same problem, but I'm not sure why. It seems like I should be able > to do: > > class B(A): >def go(self): >... >super(self).go() > > I can create a super() that does this as follows: > > _super = super > def super(obj, cls=None): >if cls is None: >return _super(type(obj), obj) >return super(cls, obj) > > I guess I'm just not sure why it wasn't done that way in the first place. > > -- > Kevin Smith > [EMAIL PROTECTED] > -- > http://mail.python.org/mailman/listinfo/python-list > -- "It is our responsibilities, not ourselves, that we should take seriously." -- Peter Ustinov -- http://mail.python.org/mailman/listinfo/python-list
Re: Modules for inclusion in standard library?
One of my votes would be for something like: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303481 or http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303770. We use something like these in the stdlib already (time_struct), but don't supply a ready solution for people to implement their own. FWIW, I'm writing all my new DB code to return tuples with named elements just to improve the readability of my programs. Anyplace where a normal positional tuple is returned could be improved with named attribute access and this wouldn't break existing code like switching to a return object would. On 27/06/05, Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote: Hello,at the moment python-dev is discussing including Jason Orendorff's path moduleinto the standard library. Do you have any other good and valued Python modules that you would think arebug-free, mature (that includes a long release distance) and useful enough tobe granted a place in the stdlib?For my part, ctypes seems like a suggestion to start with. Reinhold--http://mail.python.org/mailman/listinfo/python-list-- "Obviously crime pays, or there'd be no crime." -- G. Gorden Liddy -- http://mail.python.org/mailman/listinfo/python-list
"Ordered" dicts
Lots and lots of people want ordered dicts it seems. Or at least, they want to be able to access their dictionary keys in order. It's in the FAQ ( http://www.python.org/doc/faq/programming.html#how-can-i-get-a-dictionary-to-display-its-keys-in-a-consistent-order) and has recently shown up as a recipe ( http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438823). I have lots of code that looks like: keys = mydict.keys() keys.sort() It seems that there should be a more straight foreward way to address this extremely common use case. How about adding optional parameters to some of the dict methods that control the order that keys are returned? For example, instead of the above lines, maybe make it: keys = mydict.keys(sorted=True) .items() could work the same way. It could probably work for .iterkeys() and .iteritems() as well, though the trivial implementation wouldn't save any memory over .keys(). Maybe we could even extend it to: keys = mydict.keys(sorted=True, reversed=True) # of something... It just seems that the community spends a lot of time working around this issue and there is a simple solution. (For a given definition of simple :) The pros: -Simple syntax that is fully backward compatible -Seems like it would save a lot of effort in education and meet a community need -Dicts are by definition unordered, "Although practicality beats purity." The cons: -May be difficult to implement the .iter*() methods efficiently. What do y'all think? Chris-- "Obviously crime pays, or there'd be no crime." -- G. Gorden Liddy -- http://mail.python.org/mailman/listinfo/python-list
Re: "Ordered" dicts
On 10/08/05, Simon Brunning <[EMAIL PROTECTED]> wrote: On 8/10/05, Chris Cioffi <[EMAIL PROTECTED]> wrote: > I have lots of code that looks like:> keys = mydict.keys()> keys.sort()keys = sorted(mydict.keys()) While the sorted() built in addressed (yet another) community desire, I don't think this addresses the underlying expectation of getting dictionary keys in some order. It works, but it feel like a kludge to me. Chris-- "Obviously crime pays, or there'd be no crime." -- G. Gorden Liddy -- http://mail.python.org/mailman/listinfo/python-list
Re: python optimization
Hi Neal, I don't believe that cpython currently does any of the optimizations you refer to below. That said, it is very reasonable to adopt "a style of coding that is highly readable, making the assumption that the compiler will do good things" when coding in Python. Python is one of the most highly optimised languages in the world along the Programmer Productivity metric. Line for line, you can pack more readable, obvious, and maintainable meaning into Python than pretty much any other language. The upshot is that then you can profile the final running code and see if it really matters that the compiler is using an extra .034 microseconds. That's my $0.028 US (damn inflation!) On 15/09/05, Neal Becker <[EMAIL PROTECTED]> wrote: I use cpython. I'm accustomed (from c++/gcc) to a style of coding that ishighly readable, making the assumption that the compiler will do good things to optimize the code despite the style in which it's written. Forexample, I assume constants are removed from loops. In general, an entityis defined as close to the point of usage as possible. I don't know to what extent these kind of optimizations are available tocpython. For example, are constant calculations removed from loops? Howabout functions? Is there a significant cost to putting a function def inside a loop rather than outside?--http://mail.python.org/mailman/listinfo/python-list-- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
OT: Anyone want a GMail account?
I've got 50 so if you want a GMail invite reply directly to me and I'll send our an invite. Chris Cioffi -- "It is our responsibilities, not ourselves, that we should take seriously." -- Peter Ustinov -- http://mail.python.org/mailman/listinfo/python-list
Re: low-end persistence strategies?
I'd like to second this one...ZODB is *extremely* easy to use. I use it in projects with anything from a couple dozen simple objects all the way up to a moderately complex system with several hundred thousand stored custom objects. (I would use it for very complex systems as well, but I'm not working on any right now...) There are a few quirks to using ZODB, and the documentation sometimes feel lite, but mostly that's b/c ZODB is so easy to use. Chris On Wed, 16 Feb 2005 15:11:46 +0100, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > Paul Rubin wrote: > > > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > >> Maybe ZODB helps. > > > > I think it's way too heavyweight for what I'm envisioning, but I > > haven't used it yet. I'm less concerned about object persistence > > (just saving strings is good enough) than finding the simplest > > possible approach to dealing with concurrent update attempts. > > And that's exactly where zodb comes into play. It has full ACID support. > Opening a zodb is a matter of three lines of code - not to be compared to > rdbms'ses. And apart from some standard subclassing, you don't have to do > anything to make your objects persistable. Just check the tutorial. > -- > Regards, > > Diez B. Roggisch > -- > http://mail.python.org/mailman/listinfo/python-list > -- "It is our responsibilities, not ourselves, that we should take seriously." -- Peter Ustinov -- http://mail.python.org/mailman/listinfo/python-list
Re: Test for structure
Perhaps you're looking for the type() built in function and the types modules? >>> type('aaa') >>> type([]) >>> import types >>> if type([]) is types.ListType: ... print 'is a list' ... is a list Chris On Wed, 16 Feb 2005 07:10:56 -0800 (PST), alex <[EMAIL PROTECTED]> wrote: > Hi there, > > how can I check if a variable is a structure (i.e. a list)? For my > special problem the variable is either a character string OR a list of > character strings line ['word1', 'word2',...] > > So how can I test if a variable 'a' is either a single character string > or a list? I tried: > > if a is list: > > but that does not work. I also looked in the tutorial and used google > to find an answer, but I did not. > > Has anyone an idea about that? > > Alex > > -- > http://mail.python.org/mailman/listinfo/python-list > -- "It is our responsibilities, not ourselves, that we should take seriously." -- Peter Ustinov -- http://mail.python.org/mailman/listinfo/python-list
Re: disk based dictionaries
I'd like to second this suggestion. While there are a few things you need to be aware of when writing your code (mostly taken care of in the latest release) it's a mostly trivial code change. (For me it was replacing a few dictionaries with PersistentMap objects and changing the base class of a few objects to Persistant from object. FWIW, I'm using ZODB to help track EDI transactions for a help desk application. Right now my database hovers in the 100MB range with several ten of thousands of objects. I also use it for single object temp storage, so I feel it works well from both the small and mid-size scale. (It probably works fine for large projects as well, I just don't have one right now...) Chris On Thu, 02 Dec 2004 18:53:44 -0600, Larry Bates <[EMAIL PROTECTED]> wrote: > You may also want to take a look at ZODB (Zope database). > It handles the pickling, storage and retrieval of all > Python objects (including dictionaries) very well. And yes > you can use ZODB without using Zope proper. > > http://www.zope.org/Products/StandaloneZODB > > http://zope.org/Members/adytumsolutions/HowToLoveZODB_PartII/HowToLoveZODB_PartI > > http://www.h7.dion.ne.jp/~harm/ZODB-Tutorial.py > > > Larry Bates > > > > > Shivram U wrote: > > Hi, > > > > I want to store dictionaries on disk. I had a look at a few modules > > like bsddb, shelve etc. However would it be possible for me to do the > > following > > > > hash[1] = [1, 2, 3] where the key is an int and not a string > > > > bsddb requires that both the key,value are string. > > shelve does support values being object but not the keys. Is there any > > module which support keys which are not strings > > > > Also how do i use disk based hashes for multidimensional hashes such as > > below > > > > #!/usr/bin/python > > > > dict={} > > dict['key1'] = {} > > dict[('key1')][('key2')] = 'value' > > > > key1=dict['key1'] > > print key1['key2'] > > > > I have read of mxBeeDict but was unable to get it work properly. I am > > not sure if it supports what i need as i was unable to get any > > documentation about it. Is the module used widely ? > > > > Below is how i am using the module > > > > bdict = BeeDict('/tmp/beedict') > > > > bdict[1] = 1 > > print bdict.keys() > > > > bdict.commit() > > bdict.close() > > > > bdict1 = BeeDict('/tmp/beedict') > > print bdict1.keys() > > print bdict1.values() > > > > > > Would it be that using disk based dictionaries once opened are as fast > > as in memory dictionaries ? > > > > Thanks in advance, > > > > Best Regards, > > Shivram U > > > > > > > > > > Confidentiality Notice > > > > The information contained in this electronic message and any attachments to > > this message are intended > > for the exclusive use of the addressee(s) and may contain confidential or > > privileged information. If > > you are not the intended recipient, please notify the sender at Wipro or > > [EMAIL PROTECTED] immediately > > and destroy all copies of this message and any attachments. > -- > http://mail.python.org/mailman/listinfo/python-list > -- "It is our responsibilities, not ourselves, that we should take seriously." -- Peter Ustinov -- http://mail.python.org/mailman/listinfo/python-list
Re: exporting imports to reduce exe size?
My first thought is what if the function you are using uses other functions(maybe not exported by the module/package)? For example: if some_func() makes a call to _some_weird_module_specific_func(), how are you going to make sure you get the _some_weird_module_specific_func function? This doesn't even start to work when the function you are interested in is also using functions from other modules/packages. Besides, what py2exe is really doing is grabbing the .pyo or .pyc files and throwing them in a zip file. Is it really worth the effort to save a 100K or so, at most? Chris On Apr 12, 2005 10:54 AM, Ron_Adam <[EMAIL PROTECTED]> wrote: > > In looking at ways to reduce the size of exe's created with py2exe, > I've noticed that it will include a whole library or module even if I > only need one function or value from it. > > What I would like to do is to import individual functions and then > export 'write' them to a common resource file and import that with > just the resources I need in them. > > Has anyone tried this? > > I'm considering using pickle to do it, but was wondering if this is > even a viable idea? > > Is it possible to pickle the name space after the imports and then > reload the name space in place of the imports later? > > Cheers, > Ron > > -- > http://mail.python.org/mailman/listinfo/python-list > -- "I was born not knowing and have had only a little time to change that here and there." -- Richard Feynman -- http://mail.python.org/mailman/listinfo/python-list
Re: Dr. Dobb's Python-URL! - weekly Python news and links (Apr 11)
+1 on _that_ being a QOTW! On 4/14/05, Simon Brunning <[EMAIL PROTECTED]> wrote: [snip] > > Try and think of something else witty to say over the next day or two > - I'm sure I can squeeze you into next week's. ;-) -- "I was born not knowing and have had only a little time to change that here and there." -- Richard Feynman -- http://mail.python.org/mailman/listinfo/python-list
Re: packages
Check out http://docs.python.org/tut/node8.html#SECTION00840 Basically a package is a directory with one or more Python modules along with the "special" module called __init__.py. Chris On 18/04/05, Mage <[EMAIL PROTECTED]> wrote: > Hello, > > I read about modules and packages in the tutorial. I think I understand > how to use packages and modules, even I know how to create a module (as > far I understand it's a simple .py) file , but I don't know how can I > create a package and when should I do it. > > Where should I look for more information? > > Mage > > -- > http://mail.python.org/mailman/listinfo/python-list > -- "I was born not knowing and have had only a little time to change that here and there." -- Richard Feynman -- http://mail.python.org/mailman/listinfo/python-list
python3: 'module' object is not callable - type is
I'm writing a little script that uses a REST API and I'm having a problem using urllib in Python 3. I had the basics working in Python 2.7, but for reasons I'm not clear on I decided to update to Python 3. (I'm in the early phases, so this isn't production by any stretch.) Python version info: sys.version_info(major=3, minor=4, micro=2, releaselevel='final', serial=0) Type() info of return object from urllib.request.urlopen: Traceback of error when trying to pprint() the object: Traceback (most recent call last): File "./test.py", line 59, in testGetAvailableCash(lc) File "./test.py", line 12, in testGetAvailableCash print(lc.available_cash(INVESTORID, AUTHKEY)) File "/Users/chris/dev/LendingClub/lendingclub.py", line 49, in available_cash return self._make_api_call(''.join((BASE_ACCOUNT_URL, investorID, "/availablecash")), authorizationKey)[u'availableCash'] File "/Users/chris/dev/LendingClub/lendingclub.py", line 40, in _make_api_call pprint(lcresponse.read()) TypeError: 'module' object is not callable The relevant code is as follows: lcrequest = urllib.request.Request(url, data, {"Authorization": authorizationKey}) lcresponse = urllib.request.urlopen(lcrequest) Any ideas on what I should be looking for? Based on the docs and examples I would expect this to work. Thanks! Chris -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to schedule my script?
Hi Juan, I don't know what platform you're on, but you've got several options. Mac: setup a launchd job, I use http://www.soma-zone.com/LaunchControl/ to do the setups Linux/unix: setup a cron job, depending on your distro launchd may also be an option. Windows: setup a scheduled job in ?? (I don't have a windows box around any more, but there was a "Scheduled Jobs" section in windows explorer back in the XP days. I assume it's still around. In all cases, you'll need to add a little code in your script to STOP at 11:59, but the OS can handle starting the script. The launchd option can also act as a watchdog to also restart the script if it fails for some reason. Hope this helps! > On Dec 17, 2014, at 2:11 PM, Juan Christian wrote: > > Ops, sorry. > > It's: 9:00 AM ~ 11:59 PM -> Running > > ... and not 9:00 AM ~ 11:50 PM -> Running > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
is pathlib Path.resolve working as intended?
Ok, I'm guessing I'm doing something wrong, but I can't see what. I'm playing around with pathlib (Python 3.4.2) on Mac OSX, Yosemite. In the past I've used os.path.expanduser() to expand paths with ~. Based on the description, I would have expected .resolve to do that automatically, but it doesn't seem to work. Is this a bug, oversight or design choice? Here's my example of what I was doing: >>> p = Path('~/.profile') >>> p PosixPath('~/.profile') >>> p.resolve >>> >>> p.resolve() Traceback (most recent call last): File "", line 1, in File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pathlib.py", line 1031, in resolve s = self._flavour.resolve(self) File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pathlib.py", line 297, in resolve return _resolve(base, str(path)) or sep File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pathlib.py", line 282, in _resolve target = accessor.readlink(newpath) File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pathlib.py", line 374, in readlink return os.readlink(path) FileNotFoundError: [Errno 2] No such file or directory: '/Users/chris/~' >>> Chris -- https://mail.python.org/mailman/listinfo/python-list
Re: is pathlib Path.resolve working as intended?
That's what I thought as well. Then I found https://bugs.python.org/issue19776 and it looks like this is a well known issue. Hopefully the patches are working and will be accepted in the next release or so. Given how often os.path.expanduser() is needed, I'm a little surprised that the pathlib module was even put in provisionally. I do like how it works, however. Paths as objects and not strings! Its a beautiful idea, just not 100% complete. PS: For those who are curious, the 2 issues that seemed to hold things up the most are non-Unix systems (Windows) and how to handle when there is no home directory. Posix only says that the results are undefined. > On Dec 24, 2014, at 8:38 AM, Skip Montanaro wrote: > p.resolve() > ... > FileNotFoundError: [Errno 2] No such file or directory: '/Users/chris/~' > > I've not used the pathlib module yet, but poked through the > documentation. Oddly enough, I saw no mention of "~". The doc for the > resolve method only mentions resolving symlinks. In addition, the > pathlib doc doesn't mention "expand" either. > > My guess is your working directory was /Users/chris, and that "~" > expansion isn't supported by pathlib. Even so, it seems like a common > enough task that I'd open a bug report/feature request at > bugs.python.org. > > Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: opening excel
You can also check out the pyExcelerator project. http://sourceforge.net/projects/pyexcelerator It seems to work reasonably well at direct Excel file manipulation. However it isn't meant as a VBA replacement kind of thing. Chris On 11/9/06, at open-networks.net"@bag.python.org timmy <"timothy> wrote: > Hello, > > has anybody got any experience opening and manilpulating excel > spreedsheets via python? it seems pythoncom allows this to happen but > i'm a total newb to it. (i usually work in the unix world) > all i need to do, is open the xls files and read values from it. > -- > http://mail.python.org/mailman/listinfo/python-list > -- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Do I want multidispatch or object plug-ins or something else?
Hello all, I've got an EDI parsing application written in Python that is becoming unwieldy to maintain. At a high level here's what it does: 1. Loops through the EDI message 1 segment at a time (think SAX XML...) 2. Once it identifies what type of transaction is being processed it creates a "sub-parser" specifically for that transaction type 3. The sub-parser marks up the EDI into HTML and extracts a fair number of statistics about the transactions. Now, my sub-parser classes are polymorphic and I've used the hierarchy to make sure I don't have repeated code in each class. HOWEVER, I'm finding it difficult to add new statistic gathering methods because the code is already rather complex. That leads me to think I've got bad design. What I _think_ I want is a way to register plug-ins that say "I work with transactions of type X,Y,Z" and then have the sub parser string together calls to the various plug-ins. The "master" sub-parser would handle the basic EDI -> HTML formatting and the plug-ins would handle gathering any statistics. I currently use introspection to figure out what segments sub-parsers are interested in and I figure I would keep doing that in the future. Can anyone point me to either an on-line or off-line resource I could use for this type of thing? Are there established "plug-in patterns" already? Part of why I'm asking is because I don't think I even have the right vocabulary to describe what I'm trying to do. Any pointers would be appreciated! Chris -- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: what are you using python language for?
I tend to do a significant amount of EDI related work:-statistical analysis-X12->HTML formattingI've do a ton of customer DB reporting. I find it easier to use Python that Crystal reports for a lot of the stuff I do so I extract data and spit out CSV files for Excel to make it look pretty. And I'm getting ready to do a fun/work project using TurboGears for a web-based migration tracking utility we need.ChrisOn 6/4/06, hacker1017 <[EMAIL PROTECTED]> wrote:im just asking out of curiosity. --http://mail.python.org/mailman/listinfo/python-list-- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Launch file based on association
Q: If I have a file called "spreadsheet.xls" how can I launch it in what ever program it is associated with? I don't care if that program is Excel or OpenOffice Calc. I just want to launch the file.Since I want to just launch the new process, naturally I looked at os.execl(). However, I can't figure out how to make it work:>>> import os>>> os.execl("c:\\spreadsheet.xls")Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\os.py", line 309, in execl execv(file, args)OSError: [Errno 8] Exec format error>>> os.execl("c:\\spreadsheet.xls", "c:\\spreadsheet.xls") Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\os.py", line 309, in execl execv(file, args)OSError: [Errno 8] Exec format error Is there some trick? I _think_ I'm doing what the docs desribe...I've tried to Google around and I can't find anything of use. Having said that, I'd really appreciate it if someone could give me the right 2 word Google search that pops up exactly what I'm looking for. ;-> Thanks!Chris-- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: Launch file based on association
On 23/01/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: Chris Cioffi wrote:> Q: If I have a file called "spreadsheet.xls" how can I launch it in what> ever program it is associated with? I don't care if that program is Excel> or OpenOffice Calc. I just want to launch the file. >>> import os>>> help(os.startfile)Help on built-in function startfile in module nt:startfile(...)startfile(filepath) - Start a file with its associated application. [snip]I knew that as soon as I asked this question someone would very simply show me why I'm a moron! ;)Thank you! Chris-- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: working with pointers
Nope, numbers too. When you do: a = 4 You are storing a reference to the literal 4 in a. >>> a = 4>>> dir(a)['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__getattribute__', '__getne wargs__', '__hash__', '__hex__', '__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__redu ce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__str__', '__sub__', '__truediv__', '__xor__'] >>> Unlike a list, there is no way to alter the interger value of 4. If we go further, and then do something like: >>> b = a>>> b4>>> Both a and b refer to the same object, in this case the 4 object. If you want a copy of the object check out the copy module. Chris On 31/05/05, Michael <[EMAIL PROTECTED]> wrote: except numbers??"Dave Brueck" <[EMAIL PROTECTED] > wrote in messagenews:[EMAIL PROTECTED]> Michael wrote:> > sorry, I'm used to working in c++ :-p> >> > if i do> > a=2> > b=a > > b=0> > then a is still 2!?> >> > so when do = mean a reference to the same object>> Always.>> > and when does it mean make a copy of the object?? >> Never.>> -Dave--http://mail.python.org/mailman/listinfo/python-list-- "I was born not knowing and have had only a little time to change that here and there." -- Richard Feynman -- http://mail.python.org/mailman/listinfo/python-list
Re: When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?
On 23 Apr 2007 17:19:15 +0200, Neil Cerutti <[EMAIL PROTECTED]> wrote: > So the question becomes: Why do Python dictionaries require keys > to be of an immutable type? Dictionary keys are hashed values. If you change the key, you change the hash and lose the pointer to the referenced object. Or: Because. ;-) Chris -- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 3131: Supporting Non-ASCII Identifiers
+1 for the pep There are plenty of ways projects can enforce ASCII only if they are worried about "contamination" and since Python supports file encoding anyway, this seems like a fairly minor change. pre-commit scripts can keep weird encoding out of existing projects and everything else can be based on per-project agreed on standards. For those who complain that they can't read the weird characters, for any reason, maybe you aren't meant to read that stuff? There may be some fragmentation and duplication of effort (A Hindi module X, a Mandarin module X and the English module X) but that seems a small price to pay for letting Python fulfill it's purpose: letting people be expressive and get the job done. People are usually more expressive in their native languages, and thinking in different languages may even expose alternative ways of doing things to the greater Python community. Chris -- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: A bug in cPickle?
On 16 May 2007 10:06:20 -0700, Victor Kryukov <[EMAIL PROTECTED]> wrote: > Hello list, > > The following behavior is completely unexpected. Is it a bug or a by- > design feature? > > Regards, > Victor. > > - > > from pickle import dumps > from cPickle import dumps as cdumps > > print dumps('1001799')==dumps(str(1001799)) > print cdumps('1001799')==cdumps(str(1001799)) > > output: > True > False > Python 2.4 gives the same behavior on Windows: ActivePython 2.4.3 Build 12 (ActiveState Software Inc.) based on Python 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from pickle import dumps >>> from cPickle import dumps as cdumps >>> print dumps('1001799') == dumps(str(1001799)) True >>> print cdumps('1001799') == cdumps(str(1001799)) False >>> print cdumps('1001799') S'1001799' p1 . >>> print cdumps(str(1001799)) S'1001799' . >>> print dumps('1001799') S'1001799' p0 . >>> print dumps(str(1001799)) S'1001799' p0 . This does seem odd, at the very least. Chris -- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Web Programming - looking for examples of solid high-traffic sites
I think the first question I would have is what kind of dynamic content are you talking about? Is this a web app kind of thing, or just a content pushing site? While Django might not be v1.0 yet, it seems very solid and stable, and perfect for quickly building powerful content based dynamic sites. Other Python frameworks might be well suited to other types of dynamic sites. (I like TurboGears for actual web apps...) Depending on your needs you might also consider a non-python solution (!) like Drupal. (I'm not a PHP fan, but since other people have done all that great work:) As others have said, there might be no framework currently in existence that meets all of your requirements. You'll need to work with your team to decide what kinds of compromises you can all live with. Chris -- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: distributing python software in jar like fashion
Hi John, I don't think eggs are a flop, however the pain they are trying to solve is generally pretty minor in the Python world vs what we often see with other languages. We're starting to see some push to move more 3rd party libraries and frameworks to eggs (ie: Turbogears) and as the developers get used to dealing with eggs we will reach a critical mass. The 2 main things holding eggs back, imo: 1. The eggs extensions aren't included in the Python std lib. 2. The Python std lib is fairly robust and we can accomplish a significant amount of work without needing 3rd party code. If eggs were included in the std lib, and/or the std lib was packaged as eggs we'd see a far more rapid uptake. The key is getting the egg extensions into the main distribution. Chris On 3/16/07, John Nagle <[EMAIL PROTECTED]> wrote: > Were Python "eggs" a flop, or what? > > We need to have one packager that everyone agrees on. > Otherwise, installs become a mess, and then you have to have > installers that handle multiple packagers. > > John Nagle > > Gary Duzan wrote: > > In article <[EMAIL PROTECTED]>, alf <[EMAIL PROTECTED]> wrote: > > > >>Hi, > >> > >>I have a small app which consist of a few .py files. Is there any way to > >>distribute it in jar like fashion as a single file I can just run python > >>on. I obviously look for platform independent solution. > >> > >>Thx in advance, A. > > > > > >There is a new package that has been discussed here recently > > called Squisher that should do what you want by packing things into > > a single pyc file. There are still some minor issues that need to > > be ironed out with running the pyc directly, but it should do > > exactly what you want Real Soon Now. > > > > http://groups.google.com/groups/search?q=group%3Acomp.lang.python+squisher&qt_s=Search > > > > Gary Duzan > > Motorola CHS > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Slightly OT: Adding Objective C to my toolbox
Question background: I've been using Python as my primary language for several years now and have done all my non-trivial development in Python. I've now got a Mac and want to do some development using the Core * features in OS X in ObjC. I know I could use the PyObjC bindings, but ObjC seems to have enough stretch-my-brain features that I think it would be fun to learn. My question: If you've learned ObjC after Python, what resources did you use? Right now I'm focusing on the free docs, but would like to pickup some decent reference books. Stuff along the lines of "Learning Python, 2nd ed" where you learn not just the basics, but also develop "real" apps in the process. Also, are there any gotcha's that got you? Curious...Thanks!-- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyrex installation on windows XP: step-by-step guide
On 28 Apr 2006 01:06:55 -0700, Julien Fiore <[EMAIL PROTECTED]> wrote: I added "step A.5" to the guide and published it on the Python wiki, sothat anyone can update it easily:http://wiki.python.org/moin/PyrexOnWindows --http://mail.python.org/mailman/listinfo/python-listThanks to Julien and everyone who's helping on this! I've tried to play around with Pyrex several months ago and didn't have the time/knowledge to figure out why things weren't working. Chris-- "A little government and a little luck are necessary in life, but only a fool trusts either of them." -- P. J. O'Rourke -- http://mail.python.org/mailman/listinfo/python-list