Re: my new project, is this the right way?
On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > Sounds like you want a key-value store. If it's a lot of data, you may > still want a "database", I think it's just relational databases that > you're trying to avoid? > > On Sun, Nov 27, 2011 at 10:41 AM, 8 Dihedral > wrote: > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > >> On Nov 14, 3:41 pm, Tracubik wrote: > >> > Hi all, > >> > i'm developing a new program. > >> > Mission: learn a bit of database management > >> > Idea: create a simple, 1 window program that show me a db of movies i've > >> > seen with few (<10) fields (actors, name, year etc) > >> > technologies i'll use: python + gtk > >> > db: that's the question > >> > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > >> > sqlite at the beginning. > >> > > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > >> > they are too complex and i'll use this in a second step) > >> > > >> > is there any general tutorial of how to start developing a database? i > >> > mean a general guide to databases you can suggest to me? > >> > Thank you all > >> > > >> > MedeoTL > >> > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way to > >> > easily convert it in a sqlite db? (maybe via csv) > >> > >> To learn DBMS you need to learn sql > >> [Note sql is necessary but not sufficient for learning DBMS] > >> I recommend lightweight approaches to start with -- others have > >> mentioned access, libreoffice-base. > >> One more lightweight playpen is firefox plugin sqlite-manager > >> > >> > Is that ok? any other db to start with? (pls don't say mysql or similar, > >> > they are too complex and i'll use this in a second step) > >> > >> Correct. First you must figure out how to structure data -- jargon is > >> normalization. > >> After that you can look at transactions, ACID, distribution and all > >> the other good stuff. > > > > If I have a fast hash library that each hash function supports insertion > > and deletion and can be frozen to be stored into the file system if desired > > and retrieved lator . Can I use several hashes to replace a database that > > is slow and expensive? > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > A database with most entries in fixed bytes and types and several types that can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 bytes, it will be saved as a file but only the file name is saved in my data base. Each entry is just a type and value stored in a row of my database. I''ll limit the number of entries in a row or so called a recored to some limit first, 1024 first. Can I do this in 1024 hashes in python ? -- http://mail.python.org/mailman/listinfo/python-list
Re: my new project, is this the right way?
On Sunday, November 27, 2011 4:29:52 PM UTC+8, 8 Dihedral wrote: > On Sunday, November 27, 2011 12:03:26 PM UTC+8, Matt Joiner wrote: > > Sounds like you want a key-value store. If it's a lot of data, you may > > still want a "database", I think it's just relational databases that > > you're trying to avoid? > > > > On Sun, Nov 27, 2011 at 10:41 AM, 8 Dihedral > > wrote: > > > On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: > > >> On Nov 14, 3:41 pm, Tracubik wrote: > > >> > Hi all, > > >> > i'm developing a new program. > > >> > Mission: learn a bit of database management > > >> > Idea: create a simple, 1 window program that show me a db of movies > > >> > i've > > >> > seen with few (<10) fields (actors, name, year etc) > > >> > technologies i'll use: python + gtk > > >> > db: that's the question > > >> > > > >> > since i'm mostly a new-bye for as regard databases, my idea is to use > > >> > sqlite at the beginning. > > >> > > > >> > Is that ok? any other db to start with? (pls don't say mysql or > > >> > similar, > > >> > they are too complex and i'll use this in a second step) > > >> > > > >> > is there any general tutorial of how to start developing a database? i > > >> > mean a general guide to databases you can suggest to me? > > >> > Thank you all > > >> > > > >> > MedeoTL > > >> > > > >> > P.s. since i have a ods sheet files (libreoffice calc), is there a way > > >> > to > > >> > easily convert it in a sqlite db? (maybe via csv) > > >> > > >> To learn DBMS you need to learn sql > > >> [Note sql is necessary but not sufficient for learning DBMS] > > >> I recommend lightweight approaches to start with -- others have > > >> mentioned access, libreoffice-base. > > >> One more lightweight playpen is firefox plugin sqlite-manager > > >> > > >> > Is that ok? any other db to start with? (pls don't say mysql or > > >> > similar, > > >> > they are too complex and i'll use this in a second step) > > >> > > >> Correct. First you must figure out how to structure data -- jargon is > > >> normalization. > > >> After that you can look at transactions, ACID, distribution and all > > >> the other good stuff. > > > > > > If I have a fast hash library that each hash function supports insertion > > > and deletion and can be frozen to be stored into the file system if > > > desired and retrieved lator . Can I use several hashes to replace a > > > database that is slow and expensive? > > > > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > A database with most entries in fixed bytes and types and several types that > can have varied lengths of 8 to 256 bytes. If an entry is larger than 256 > bytes, it will be saved as a file but only the file name is saved in my data > base. > > Each entry is just a type and value stored in a row of my database. > I''ll limit the number of entries in a row or so called a recored to some > limit first, 1024 first. > > Can I do this in 1024 hashes in python ? Sorry I 'll use (k=column_in_a_row, v=value) and (k=value, v=column_in_a_row) Thus, two hashes per column in my database, therefore 2048 hashes to manage the data base. I'll reserve 24 entries per row for book keeping. Thus the record can have 1000 entries maximum first. The number of record can be very large. Each value will be a string with type 1 byte and the stored value 8 to 255 bytes represented as a string when fetching the value can be auto-transformed according to the type. The sort and search will be rewritten for the comparison operator. -- http://mail.python.org/mailman/listinfo/python-list
Re: sick of distribute, setup, and all the rest...
Agreed. I recently gave Haskell a go, and it was remarkable how similar the package management is to Python's. How well does the new "packaging" (set for release in Python 3.3?) module deal with the problems? With a better package management system, the half of the standard library that nobody uses can be unceremoniously dumped, and their more recent upstream versions used correctly. Even distutils itself is "obsolete", the first recommendation people give is to replace it with distribute and/or pip. On Sun, Nov 27, 2011 at 4:28 AM, rusi wrote: > On Nov 26, 6:40 pm, kj wrote: >> it's an all-out disgrace. >> >> when is python going to get a decent module distribution system??? >> >> and don't tell me to do it myself: it's clear that the sorry >> situation we have now is precisely that too many programmers without >> the requisite expertise or policy-making authority have decided to >> pitch in. This is something for GvR and his top Python core library >> team to do, because the problems are as much policy and institutional >> ones as they are technical (programming) ones. > > I second this. > > The only thing I disagree about is that GvR is 'top' enough to handle > this. > For example on my debian box my python system is a mishmash of debian- > apt-packages, > eggs, and hand-installed stuff. [I believe I tried something like > pypi and did not succeed -- dont exactly remember] > So for systems like mine python and apt need to talk courteously to > each other -- not possible for the likes of u&me; hard even for the > likes of GvR. > > Frankly, this is not great but could be much worse. Some years ago > when I worked with Ruby on Rails the rails that came from debian was > an travesty. After some suffering I gathered that the optimal > diplomacy was: > - ruby from apt > - gem hand installed > - rails from gem > > While Ive never seen anything as ridiculous as the debian-rails in the > python world, its still always a hobson choice: use a deb package > that will cleanly install, deinstall, upgrade etc but is out of date > or use a fresh and shiny egg that messes up the system. > > Haskell's cabal/hackage system is just as much a mess > http://www.reddit.com/r/haskell/comments/f3lh5/haskells_own_dll_hell/ > > In short the mess arises from this that each of these languages comes > up with its own package management system, neglecting the fact that > the language invariably exists in a larger ecosystem > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Return of an old friend
On Sun, Nov 27, 2011 at 4:38 AM, Chris Angelico wrote: > On Sun, Nov 27, 2011 at 4:11 AM, rusi wrote: >> Hi Rick! >> Glad to see you back! >> [Courts can be dull places without jesters ye-know!] > > So, what... you'd take someone to court for being funny? That sounds > like the -other- Pythons. > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list > Burn!! :D -- http://mail.python.org/mailman/listinfo/python-list
why is bytearray treated so inefficiently by pickle?
Hi, A bytearray is pickled (using max protocol) as follows: >>> pickletools.dis(pickle.dumps(bytearray([255]*10),2)) 0: \x80 PROTO 2 2: cGLOBAL '__builtin__ bytearray' 25: qBINPUT 0 27: XBINUNICODE u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' 52: qBINPUT 1 54: USHORT_BINSTRING 'latin-1' 63: qBINPUT 2 65: \x86 TUPLE2 66: qBINPUT 3 68: RREDUCE 69: qBINPUT 4 71: .STOP >>> bytearray("\xff"*10).__reduce__() (, (u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff', 'latin-1'), None) Is there a particular reason it is encoded so inefficiently? Most notably, the actual *bytes* in the bytearray are represented by an UTF-8 string. This needs to be transformed into a unicode string and then encoded back into bytes, when unpickled. The thing being a bytearray, I would expect it to be pickled as such: a sequence of bytes. And then possibly converted back to bytearray using the constructor that takes the bytes directly (BINSTRING/BINBYTES pickle opcodes). The above occurs both on Python 2.x and 3.x. Any ideas? Candidate for a patch? Irmen. -- http://mail.python.org/mailman/listinfo/python-list
Buy Google AdWords Vouchers & Coupons
Hi Friends, Do You Need Google AdWords Vouchers. You Can Get All Coupons Of $100, $75, $50 Credit. Just Visit http://buyadwordsvoucher.tk/ To Get Them. You Will Receive Coupon With In 12 Hrs 100%. Thankyou & Good Luck In Google AdWords. adwords voucher, adwords coupon, buy adwords voucher, buy adwords coupon, adwords credit, adwords Gutschein, adwords buono, adwords kupon -- http://mail.python.org/mailman/listinfo/python-list
hii
okk -- http://mail.python.org/mailman/listinfo/python-list
Buy Google AdWords Vouchers & Coupons
Hi Friends, Do You Need Google AdWords Vouchers. You Can Get All Coupons Of $100, $75, $50 Credit. Just Visit http://buyadwordsvoucher.tk/ To Get Them. You Will Receive Coupon With In 12 Hrs 100%. Thankyou & Good Luck In Google AdWords. adwords voucher, adwords coupon, buy adwords voucher, buy adwords coupon, adwords credit, adwords Gutschein, adwords buono, adwords kupon -- http://mail.python.org/mailman/listinfo/python-list
[ANN] Android Debug Bridge (ADB) Scripting Language For Android (SL4A) convenience library
hello, The information on ADB / SL4A is quiet overwhelming. Despite that, especially for people, not familiar with Linux, it's not an easy task to get their first program running. This library allows you to easy upload and run Python files on a Android device, without pressing any button on the Android device. After installing SL4A and Py4A on the Android device, and ADB on the hostmachine, it's just a matter of connecting the USB cable between Android device and host-PC, and run the program. One of the simplest program that will run out of the box (without touching any button on the Android device) : # * from adb_sl4a_support import ADB_Connection ADB = ADB_Connection () print ADB # Create a simple program Simple_Program = """ import android droid = android.Android (( '%s', %s )) droid.makeToast ( "Wasn't that easy?") """ % ( ADB.SL4A_Servers [-1][0], ADB.SL4A_Servers [-1][1] ) # execute the program (this will run the program from the host PC !!) exec ( Simple_Program ) # * you can find the library here: http://code.google.com/p/pylab-works/downloads/detail?name=adb_sl4a_support.py&can=2&q= cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: suitability of python
On 2011-11-24, Rudra Banerjee wrote: > I am a newbie in python and basically i use python for postprocessing > like plotting, data manipulation etc. > Based on ease of programming on python I am wondering if I can consider > it for the main development as well. My jobs (written on fortran) runs > for weeks and quite CPU intensive. How python works on these type of > heavy computation? You'll have to tell us what "these type of heavy computation" are before we can answer. There are a _lot_ of heavy-duty computational libraries (many of them written in FORTAN) that have been interfaced to Python (BLAS and so on). If the heavy lifting can be done by those libraries, Python might be very suitable. You might want to check out scipy, Scientific Python, and the Enthought python distro. http://www.scipy.org/ http://dirac.cnrs-orleans.fr/plone/software/scientificpython/overview/ http://www.enthought.com/products/epd.php -- http://mail.python.org/mailman/listinfo/python-list
Re: suitability of python
Rudra Banerjee, 24.11.2011 12:31: I am a newbie in python and basically i use python for postprocessing like plotting, data manipulation etc. Based on ease of programming on python I am wondering if I can consider it for the main development as well. My jobs (written on fortran) runs for weeks and quite CPU intensive. How python works on these type of heavy computation? You already got a lot of answers that pointed you to the scientific computing tools that are available for Python. The reason why they exist is because (and nowadays also "why") Python is so extremely popular in that field: it's an easy to learn and use language and the standard implementation (often referred to as CPython) makes it really easy to interface with external code (C/C++/Fortran/etc.) in a very efficient way. In addition to looking at NumPy/SciPy and/or Sage (depending on the kind of computations you are involved with), you should also look at fwrap and Cython. They will allow you to easily wrap your existing Fortran code for Python, and to quickly write very fast glue code for the two language environments. Thus, you can keep your existing code as it is, and use and control it from Python, using all the nice tools that Python provides for quickly writing anything from distributed code and test suites to graphical user interfaces for visualising your data. Since you specifically asked about plotting, don't miss out on matplotlib. Stefan -- http://mail.python.org/mailman/listinfo/python-list
lxml precaching DTD for document verification.
Hi, I'd like to verify some (x)html / / html5 / xml documents from a server. These documents have a very limited number of different doc types / DTDs. So what I would like to do is to build a small DTD cache and some code, that would avoid searching the DTDs over and over from the net. What would be the best way to do this? I guess, that the fields od en ElementTre, that I have to look at are docinfo.public_id docinfo.system_uri There's also mentioning af a catalogue, but I don't know how to use a catalog and how to know what is inside my catalogue and what isn't. Below a non working skeleto (first shot): - Would this be the right way?? ### ufnctions with '???' are not implemented / are the ones ### where I don't know whether they exist alreday. import os import urllib from lxml import etree cache_dir = os.path.join(os.environ['HOME'], ''.my_dtd_cache') def get_from_cache(docinfo): """ the function which I'd like to implement most efficiently """ fpi = docinfo.public_id uri = docinfo.system_uri dtd = ???get_from_dtd_cache(fpi, uri) if dtd is not None: return dtd # how can I check what is in my 'catalogue' if ???dtd_in_catalogue(??): return ???get_dtd_from_catalogue??? dtd_rdr = urllib.urlopen(uri) dtd_filename = ???create_cache_filename(docinfo) (fname, _headers) = urllib.urlretrieve(uri, dtd_filename) return etree.DTD(fname) def check_doc_cached(filename): """ function, which should report errors if a doc doesn't validate. """ doc = etree.parse(filename) dtd = get_from_cache(doc.docinfo) rslt = dtd.validate(doc) if not rlst: print "validate error:" print(dtd.error_log.filter_from_errors()[0]) -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml precaching DTD for document verification.
In article , Gelonida N wrote: > I'd like to verify some (x)html / / html5 / xml documents from a server. I'm sure you could roll your own validator with lxml and some DTDs, but you would probably save yourself a huge amount of effort by just using the validator the W3C provides (http://validator.w3.org/). -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml precaching DTD for document verification.
In Roy Smith writes: > In article , > Gelonida N wrote: > > > I'd like to verify some (x)html / / html5 / xml documents from a server. > I'm sure you could roll your own validator with lxml and some DTDs, but > you would probably save yourself a huge amount of effort by just using > the validator the W3C provides (http://validator.w3.org/). With regards to XML, he may mean that he wants to validate that the document conforms to a specific format, not just that it is generally valid XML. I don't think the w3 validator will do that. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list
Re: sick of distribute, setup, and all the rest...
On 27Nov2011 23:54, Matt Joiner wrote: | Agreed. I recently gave Haskell a go, and it was remarkable how | similar the package management is to Python's. | | How well does the new "packaging" (set for release in Python 3.3?) | module deal with the problems? | | With a better package management system, the half of the standard | library that nobody uses can be unceremoniously dumped, and their more | recent upstream versions used correctly. Even distutils itself is | "obsolete", the first recommendation people give is to replace it with | distribute and/or pip. Ah the cheery optimism of the end user. Package systems have a lot of fun complications. Install for the user only? For the whole system? Architecture specific? What if people want access to different versions of a package? What about vendor supplied (eg RPM) versus user obtained? They'll fight, one way or another. What if policy has user supplied installing to its own tree (sensible to avoid conflicts) - the fetch/install kit need to know this. What about stability? Your "half of the standard library that nobody uses can be unceremoniously dumped, and their more recent upstream versions used correctly" leads to bugs in the apps that use the packages if they depend on particular versions/APIs. The stdlib is generally quite careful about breaking APIs but other packagers often are less so. I can make this list bigger or more detailed if you want. All package systems have these issues. They're not as trivial as you might imagine. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ The problem with elections is that the government always wins. - Chris Rudram -- http://mail.python.org/mailman/listinfo/python-list
Re: Using the Python Interpreter as a Reference
On Nov 26, 1:53 pm, Rick Johnson wrote: > On Nov 20, 6:46 pm, Travis Parks wrote: > > > Hello: > > > I am currently working on designing a new programming language. It is > > a compiled language, but I still want to use Python as a reference. > > Python has a lot of similarities to my language, such as indentation > > for code blocks, > > I hope you meant to say "*forced* indention for code blocks"! "Forced" > being the key word here. What about tabs over spaces, have you decided > the worth of one over the other or are you going to repeat Guido's > folly? > > And please, i love Python, but the language is a bit asymmetrical. Do > try to bring some symmetry to this new language. You can learn a lot > from GvR's triumphs, however, you can learn even more from his follys. Personally, I find a lot of good things in Python. I thinking tabs are out-of-date. Even the MAKE community wishes that the need for tabs would go away and many implementations have done just that. I have been seriously debating about whether to force a specific number of spaces, such as the classic 4, but I am not sure yet. Some times, 2 or even 8 spaces is appropriate (although I'm not sure when). I have always found the standard library for Python to be disjoint. That can be really beneficial where it keeps the learning curve down and the size of the standard modules down. At the same time, it means re-learning whenever you use a new module. My language combines generators and collection initializers, instead of creating a whole new syntax for comprehensions. [| for i in 0..10: for j in 0.10: yield return i * j |] Lambdas and functions are the same thing in my language, so no need for a special keyword. I also distinguish between initialization and assignment via the let keyword. Also, non-locals do not need to be defined explicitly, since the scoping rules in Unit are far more "anal". In reality though, it takes a certain level of arrogance to assume that any language will turn out without bumps. It is like I was told in college long ago, "Only the smallest programs are bug free." I think the same thing could be said for a language. The only language without flaws would be so small that it would be useless. I love these types of discussions though, because it helps me to be aware. When designing a language, it is extremely helpful to hear what language features have led to problems. For instance, C#'s foreach loops internally reuse a variable, which translates to something like this: using (IEnumerator enumerator = enumerable.GetEnumerator()) { T current; while (enumerator.MoveNext()) { current = enumerator.Current; // inner loop code goes here } } Since the same variable is reused, threads referencing the loop variable work against whatever value is currently in the variable, rather than the value when the thread was created. Most of the time, this means every thread works against the same value, which isn't the expected outcome. Moving the variable inside the loop _may_ help, but it would probably be optimized back out of the loop by the compiler. With the growth of threaded applications, these types of stack-based optimizations may come to an end. That is why it is important for a next-gen language to have a smarter stack - one that is context sensitive. In Unit, the stack grows and shrinks like a dynamic array, at each scope, rather than at the beginning and end of each function. Sure, there's a slight cost in performance, but a boost in consistency. If a programmer really wants the performance, they can move the variable out of the loop themselves. In fact, there are a lot of features in Unit that will come with overhead, such as default arguments, non-locals, function-objects, etc. However, the game plan is to avoid the overhead if it isn't used. Some things, such as exception handling, will be hard to provide without overhead. My belief is that, provided a tool, most developers will use it and accept the slight runtime overhead. I think everyone has an idea about what would make for the perfect language. I am always willing to entertain ideas. I have pulled from many sources: C#, Java, Python, JavaScript, F#, Lisp and more. The hope is to provide as much expression with as much consistency as possible. Just the other day I spent 2 hours trying to determine how to create a null pointer (yeah, it took that long). let pi = null as shared * Integer32 # null is always a pointer Originally, I wanted 'as' to be a safe conversion. However, I decided to make use of the 'try' keyword to mean a safe conversion. let nd = try base as shared * Derived let d = if nd.Succeeded: nd.Value else: null # or, shorthand let i = try Integer32.Parse("123") else 0 Of course, the last line could cost performance wise. For that reason, Unit will allow for "try" versions of methods. let Parse = public static method (value: String) throws(FormatException UnderflowException OverflowException) returns(Integer32)
Re: Using the Python Interpreter as a Reference
On Sun, 27 Nov 2011 14:21:01 -0800, Travis Parks wrote: > On Nov 26, 1:53 pm, Rick Johnson wrote: >> On Nov 20, 6:46 pm, Travis Parks wrote: >> >> > Hello: >> >> > I am currently working on designing a new programming language. It is >> > a compiled language, but I still want to use Python as a reference. >> > Python has a lot of similarities to my language, such as indentation >> > for code blocks, >> >> I hope you meant to say "*forced* indention for code blocks"! "Forced" >> being the key word here. What about tabs over spaces, have you decided >> the worth of one over the other or are you going to repeat Guido's >> folly? >> >> And please, i love Python, but the language is a bit asymmetrical. Do >> try to bring some symmetry to this new language. You can learn a lot >> from GvR's triumphs, however, you can learn even more from his follys. > > Personally, I find a lot of good things in Python. I thinking tabs are > out-of-date. Even the MAKE community wishes that the need for tabs would > go away and many implementations have done just that. I have been > seriously debating about whether to force a specific number of spaces, > such as the classic 4, but I am not sure yet. Some times, 2 or even 8 > spaces is appropriate (although I'm not sure when). > > I have always found the standard library for Python to be disjoint. That > can be really beneficial where it keeps the learning curve down and the > size of the standard modules down. At the same time, it means > re-learning whenever you use a new module. > > My language combines generators and collection initializers, instead of > creating a whole new syntax for comprehensions. > > [| for i in 0..10: for j in 0.10: yield return i * j |] > > Lambdas and functions are the same thing in my language, so no need for > a special keyword. I also distinguish between initialization and > assignment via the let keyword. Also, non-locals do not need to be > defined explicitly, since the scoping rules in Unit are far more "anal". > > In reality though, it takes a certain level of arrogance to assume that > any language will turn out without bumps. It is like I was told in > college long ago, "Only the smallest programs are bug free." I think the > same thing could be said for a language. The only language without flaws > would be so small that it would be useless. > > I love these types of discussions though, because it helps me to be > aware. When designing a language, it is extremely helpful to hear what > language features have led to problems. For instance, C#'s foreach loops > internally reuse a variable, which translates to something like this: > > using (IEnumerator enumerator = enumerable.GetEnumerator()) > { > T current; > while (enumerator.MoveNext()) > { > current = enumerator.Current; > // inner loop code goes here > } > } > > Since the same variable is reused, threads referencing the loop variable > work against whatever value is currently in the variable, rather than > the value when the thread was created. Most of the time, this means > every thread works against the same value, which isn't the expected > outcome. Moving the variable inside the loop _may_ help, but it would > probably be optimized back out of the loop by the compiler. With the > growth of threaded applications, these types of stack-based > optimizations may come to an end. That is why it is important for a > next-gen language to have a smarter stack - one that is context > sensitive. In Unit, the stack grows and shrinks like a dynamic array, at > each scope, rather than at the beginning and end of each function. Sure, > there's a slight cost in performance, but a boost in consistency. If a > programmer really wants the performance, they can move the variable out > of the loop themselves. > > In fact, there are a lot of features in Unit that will come with > overhead, such as default arguments, non-locals, function-objects, etc. > However, the game plan is to avoid the overhead if it isn't used. Some > things, such as exception handling, will be hard to provide without > overhead. My belief is that, provided a tool, most developers will use > it and accept the slight runtime overhead. > > I think everyone has an idea about what would make for the perfect > language. I am always willing to entertain ideas. I have pulled from > many sources: C#, Java, Python, JavaScript, F#, Lisp and more. The hope > is to provide as much expression with as much consistency as possible. > Just the other day I spent 2 hours trying to determine how to create a > null pointer (yeah, it took that long). > > let pi = null as shared * Integer32 # null is always a pointer > > Originally, I wanted 'as' to be a safe conversion. However, I decided to > make use of the 'try' keyword to mean a safe conversion. > > let nd = try base as shared * Derived let d = if nd.Succeeded: nd.Value > else: null # or, shorthand let i = try Integer32.Parse("123") else 0 > > Of cour
Re: Using the Python Interpreter as a Reference
On Sun, 27 Nov 2011 14:21:01 -0800, Travis Parks wrote: > Personally, I find a lot of good things in Python. I thinking tabs are > out-of-date. Even the MAKE community wishes that the need for tabs would > go away and many implementations have done just that. Tabs have every theoretical advantage and only one practical disadvantage: the common toolsets used by Unix programmers are crap in their handling of tabs, and instead of fixing the toolsets, they blame the tabs. The use of spaces as indentation is a clear case of a technically worse solution winning over a better solution. > I have been > seriously debating about whether to force a specific number of spaces, > such as the classic 4, but I am not sure yet. Some times, 2 or even 8 > spaces is appropriate (although I'm not sure when). Why on earth should your language dictate the width of an indentation? I can understand that you might care that indents are consistent within a single source code unit (a file?), but anything more than that is just obnoxious. > I have always found the standard library for Python to be disjoint. That > can be really beneficial where it keeps the learning curve down and the > size of the standard modules down. At the same time, it means > re-learning whenever you use a new module. I know what disjoint means, but I don't understand what you think it means for a software library to be disjoint. I don't understand the rest of the paragraph. > My language combines generators and collection initializers, instead of > creating a whole new syntax for comprehensions. > > [| for i in 0..10: for j in 0.10: yield return i * j |] Are we supposed to intuit what that means? Is | a token, or are the delimiters [| and |] ? Is there a difference between iterating over 0..10 and iterating over what looks like a float 0.10? What is "yield return"? > Lambdas and functions are the same thing in my language, so no need for > a special keyword. That does not follow. Lambdas and def functions are the same thing in Python, but Python requires a special keyword. > I also distinguish between initialization and > assignment via the let keyword. What does this mean? I can guess, but I might guess wrong. > Also, non-locals do not need to be > defined explicitly, since the scoping rules in Unit are far more "anal". What does this mean? I can't even guess what you consider more anal scoping rules. > In reality though, it takes a certain level of arrogance to assume that > any language will turn out without bumps. It is like I was told in > college long ago, "Only the smallest programs are bug free." I think the > same thing could be said for a language. The only language without flaws > would be so small that it would be useless. I'm pretty sure that being so small that it is useless would count as a flaw. What does it mean to say that a language is "small"? A Turing Machine is a pretty small language, with only a few instructions: step forward, step backwards, erase a cell, write a cell, branch on the state of the cell. And yet anything that can be computed, anything at all, can be computed by a Turning Machine: a Turing Machine can do anything you can do in C, Lisp, Fortran, Python, Java... and very probably anything you can (mentally) do, full stop. So what does that mean about "small" languages? On the other hand, take Epigram, a functional programming language: http://en.wikipedia.org/wiki/Epigram_(programming_language) It is *less* powerful than a Turing Machine, despite being far more complex. Similarly languages like regular expressions, finite automata and context-free grammers are more complex, "bigger", possibly with dozens or hundreds of instructions, and yet less powerful. Likewise for spreadsheets without cycles. Forth is much smaller than Java, but I would say that Forth is much, much more powerful in some sense than Java. You could write a Java compiler in Forth more easily than you could write a Forth compiler in Java. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Using the Python Interpreter as a Reference
On Mon, Nov 28, 2011 at 10:55 AM, Steven D'Aprano wrote: > What does it mean to say that a language is "small"? > > A Turing Machine is a pretty small language, with only a few > instructions: step forward, step backwards, erase a cell, write a cell, > branch on the state of the cell. And yet anything that can be computed, > anything at all, can be computed by a Turning Machine... Ook has only three tokens (okay, it's a derivative of BrainF** so it kinda has eight, but they're implemented on three). It's Turing-complete, but it is so small as to be useless for any practical purposes. The ONLY way to use Ook for any useful code would be to write an interpreter for another language in it, and use that other language. However, Ook can be proven to be flawless, as can an Ook interpreter, much more easily than a full-featured language like Python or C. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml precaching DTD for document verification.
On 11/27/2011 10:33 PM, John Gordon wrote: > In Roy Smith > writes: > >> In article , >> Gelonida N wrote: >> >>> I'd like to verify some (x)html / / html5 / xml documents from a server. > >> I'm sure you could roll your own validator with lxml and some DTDs, but >> you would probably save yourself a huge amount of effort by just using >> the validator the W3C provides (http://validator.w3.org/). This validator requires that I post the code to some host. The contents that I'd like to verify is intranet contents, which I am not allowed to post to an external site. > > With regards to XML, he may mean that he wants to validate that the > document conforms to a specific format, not just that it is generally > valid XML. I don't think the w3 validator will do that. > Basically I want to integrate this into a django unit test. I noticed, that some of of the templates generate documents with mismatching DTD headers / contents. All of the HTML code is parsable as xml (if it isn't it's a bug) There are also some custom XML files, which have their specific DTDs So I thought about validating some of the generated html with lxml. the django test environment allows to run test clients, which are supposedly much faster than a real http client. -- http://mail.python.org/mailman/listinfo/python-list
Re: python shell that saves history of typed in commands that will persist between reboots
On Nov 15, 10:38 pm, goldtech wrote: > Hi, > > Using Windows. Is there a python shell that has a history of typed in > commands? > > I don't need output of commands just what I typed it. I need it to > save between sessions - something that no shell seems to do. If I > reboot there will still be a command history somewhere. > > Like bash history in Linux. > > Thanks Something that might be of interest is wxPython's pyslicesshell.py it's not commandline in console window but the interpreter in a window. And you can save it. I haven't used it lately by there's also PythonWin http://python.net/crew/skippy/win32/PythonwinPreview.html -- http://mail.python.org/mailman/listinfo/python-list
Re: why is bytearray treated so inefficiently by pickle?
On 11/27/2011 9:33 AM, Irmen de Jong wrote: Hi, A bytearray is pickled (using max protocol) as follows: pickletools.dis(pickle.dumps(bytearray([255]*10),2)) 0: \x80 PROTO 2 2: cGLOBAL '__builtin__ bytearray' 25: qBINPUT 0 27: XBINUNICODE u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' 52: qBINPUT 1 54: USHORT_BINSTRING 'latin-1' 63: qBINPUT 2 65: \x86 TUPLE2 66: qBINPUT 3 68: RREDUCE 69: qBINPUT 4 71: .STOP bytearray("\xff"*10).__reduce__() (, (u'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff', 'latin-1'), None) Is there a particular reason it is encoded so inefficiently? Most notably, the actual *bytes* in the bytearray are represented by an UTF-8 string. This needs to be transformed into a unicode string and then encoded back into bytes, when unpickled. The thing being a bytearray, I would expect it to be pickled as such: a sequence of bytes. And then possibly converted back to bytearray using the constructor that takes the bytes directly (BINSTRING/BINBYTES pickle opcodes). The above occurs both on Python 2.x and 3.x. Any ideas? Candidate for a patch? Possibly. The two developers listed as particularly interested in pickle are 'alexandre.vassalotti,pitrou' (antoine), so if you do open a tracker issue, add them as nosy. Take a look at http://www.python.org/dev/peps/pep-3154/ by Antoine Pitrou or forwary your message to him. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Proper way to delete/kill a logger?
I've been trying to migrate some code to using the standard python logging classes/objects. And they seem quite capable of doing what I need them to do. Unfortunately there's a problem in my unit tests. It's fairly common to have to create quite a few entities in the course of a series of tests. What appears to be happening is that the loggers don't get entirely eliminated, so that new invocations end up spewing output messages from each of the loggers that were started with this invocation of the python interpreter. I haven't found a function within the logging module that completely kills a given instance. The removeHandler() function seems to leave a stdout/stderr output even if all the assigned handlers have been removed. I've tried a few workarounds, such as increasing the level to an absurdly large level, which mostly kinda works, and killing the old entity before creating the new test version. There is probably something simple that I'm missing. If you know what that is, please point me to that fine manual - I'd appreciate it. Thanks! -f -- http://mail.python.org/mailman/listinfo/python-list
Re: sick of distribute, setup, and all the rest...
On Nov 28, 2:46 am, Cameron Simpson wrote: > On 27Nov2011 23:54, Matt Joiner wrote: > | Agreed. I recently gave Haskell a go, and it was remarkable how > | similar the package management is to Python's. > | > | How well does the new "packaging" (set for release in Python 3.3?) > | module deal with the problems? > | > | With a better package management system, the half of the standard > | library that nobody uses can be unceremoniously dumped, and their more > | recent upstream versions used correctly. Even distutils itself is > | "obsolete", the first recommendation people give is to replace it with > | distribute and/or pip. > > Ah the cheery optimism of the end user. > Package systems have a lot of fun complications. > > Install for the user only? For the whole system? > Architecture specific? > What if people want access to different versions of a package? > What about vendor supplied (eg RPM) versus user obtained? They'll fight, > one way or another. What if policy has user supplied installing to its > own tree (sensible to avoid conflicts) - the fetch/install kit need to > know this. > What about stability? Your "half of the standard library that nobody uses can > be unceremoniously dumped, and their more recent upstream versions used > correctly" leads to bugs in the apps that use the packages if they depend on > particular versions/APIs. The stdlib is generally quite careful about > breaking APIs but other packagers often are less so. > > I can make this list bigger or more detailed if you want. All package > systems have these issues. They're not as trivial as you might imagine. Where is there any implication that there are not issues or that they are trivial? At the end of his life Dijkstra said: The single biggest problem in computer science is how not to make a mess of it; that problem remains unsolved. The OP simply expressed a wish for improvement and I seconded that [and pls ignore ranters with oedipal problems] >From my post from a few months >http://mail.python.org/pipermail/python-list/2011-May/1271765.html If I may restate: Too much mindshare is devoted to all the linguistic features of python: garbage collection, identation, metaclasses and all that other good stuff from the 70s and too little to extra-linguistic ecosystem features below: If the linguistic features were all that mattered Lisp would be the king of languages today > > >| Area | Tool(s)| > >|--+| > >| packaging| distutils, setuptools, | > >| | distutils2, distribute | > >| | Native tools (eg apt) | > >| versioning | hg, git, bzr | > >| multiple pythons | virtualenv | > >| ?? | tox| > >| testing | unittest, nose, pytest | > >| build| scons, make... | > >| deployment | fabric | > -- http://mail.python.org/mailman/listinfo/python-list
RE: Automatic import of submodules
-Original Message- From: Massi [mailto:massi_...@msn.com] Sent: 25/11/2011 6:30 PM To: python-list@python.org Subject: Automatic import of submodules Hi everyone, in my project I have the following directory structure: plugins | -- wav_plug | -- __init__.py -- WavPlug.py -- mp3_plug | -- __init__.py -- Mp3Plug.py ... -- etc_plug | -- __init__.py -- EtcPlug.py Every .py file contain a class definition whose name is identical to to the file name, so in my main script I have to import each submodule like that: from plugins.wav_plug.WavPlug import WavPlug from plugins.wav_plug.Mp3Plug import Mp3Plug and so on. This is uncomfortable, since when a new plugin is added I have to import it too. So my question is, is it possible to iterate through the 'plugins' directory tree in order to automatically import the submodules contained in each subdirectory? I googled and found that the pkgutil could help, but it is not clear how. Any hints? Thanks in advance. = What you could do is : Instead of importing method wise , import the module. from plugins.wav_plug import WavPlug you can then use like this then WavPlug.WavPlug This will avoid the-every time importing of each method Regards, Shambhu -- http://mail.python.org/mailman/listinfo/python-list
Re: sick of distribute, setup, and all the rest...
In article <46c11371-411a-4ba0-89b9-967e2f83e...@k5g2000pre.googlegroups.com>, rusi wrote: > If the linguistic features were all that mattered Lisp would be the > king of languages today (that (is (one (of (the (most (absurd (statements (I've (read (in (a (long (time)) -- http://mail.python.org/mailman/listinfo/python-list
Re: sick of distribute, setup, and all the rest...
rusi wrote: > While Ive never seen anything as ridiculous as the debian-rails in the > python world, its still always a hobson choice: use a deb package > that will cleanly install, deinstall, upgrade etc but is out of date > or use a fresh and shiny egg that messes up the system. The only time I use the OS package manager to install a Python library is if some other application requires it as a dependency. If you're not making the distinction between your system install of Python and your development install, you're really inviting a whole world of pain and confusion on yourself. With that approach in mind, I've never had any real issues using pip, virtualenv etc for managing my development environment. -- http://mail.python.org/mailman/listinfo/python-list
Re: sick of distribute, setup, and all the rest...
On Nov 28, 9:37 am, alex23 wrote: > With that approach in mind, I've never had any real issues using pip, > virtualenv etc for managing my development environment. Yes that is in a way my point also: we discuss (things like) pip, virtualenv etc too little. Try working out the ratio of the number of helps/tutorials on functions/lists/types/classes to those on these extra-linguistic features needed for environment/build/deployment/versioning and you can see the skewness of focus -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml precaching DTD for document verification.
Gelonida N, 27.11.2011 18:57: I'd like to verify some (x)html / / html5 / xml documents from a server. These documents have a very limited number of different doc types / DTDs. So what I would like to do is to build a small DTD cache and some code, that would avoid searching the DTDs over and over from the net. What would be the best way to do this? Configure your XML catalogues. I guess, that the fields od en ElementTre, that I have to look at are docinfo.public_id docinfo.system_uri Yes, catalogue lookups generally happen through the public ID. There's also mentioning af a catalogue, but I don't know how to use a catalog and how to know what is inside my catalogue and what isn't. Does this help? http://lxml.de/resolvers.html#xml-catalogs http://xmlsoft.org/catalog.html They should normally come pre-configured on Linux distributions, but you may have to install additional packages with the respective DTDs. Look for any packages with "dtd" and "html" in their name, for example. Stefan -- http://mail.python.org/mailman/listinfo/python-list