Reading properties file in Python, except using ConfigParser()
Hi All, How to read properties file in Python? I found ConfigParser() but it has a 'section' limitation, so looking for other alternatives. Thanks, Harsh -- http://mail.python.org/mailman/listinfo/python-list
How to create a login screen using core python language without using any framework
I need to develop a simple login page using Python language with two fields and a button, like: Username, Password, Login I know there are some beautiful Python frameworks like Django, Grok, WebPy, TurboGears which support web development using Python, but mine is a basic requirement consisting of only 3 screens (pages): * 1st page - Login page (Redirects to 2nd page when login button is clicked) * 2nd page - Page with records in the form of a list, with an option for adding new records (Redirects to 3rd page when "Add Records" button is clicked) * 3rd page - Page with fields, which are saved as records for the list on 2nd page (After entering details and clicking Submit) So, I have decided to develop the above functionality using Python **without** using any framework, so that I can have flexibility as well as write my own code. 1. Is it possible to create a login page using Python without using a framework? 2. I haven't worked on web services and don't know the basics of web development in Python. 3. If possible, can you provide me an example on how to create a login page using Python and achieve the functionality described above? -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading properties file in Python, except using ConfigParser()
On 2012-10-05 09:20, [email protected] wrote: Hi All, How to read properties file in Python? I found ConfigParser() but it has a 'section' limitation, so looking for other alternatives. http://wiki.python.org/moin/ConfigParserShootout -- http://mail.python.org/mailman/listinfo/python-list
Re: final question: logging to stdout and updating files
On 04/10/2012 15:27, Chris Angelico wrote: ensured that Australia won the next Test Match ChrisA may need to schedule surgical detongueing of his cheek I'll arrange the cheek detonguing very cheaply after a comment like that :) -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I hide my stack frames in a TestCase subclass?
Manuel Pégourié-Gonnard wrote: > Peter Otten scripsit : > >> David Banks wrote: >> >>> Note that the custom assert method causes a stack trace with two frames, >>> one inside the method itself, whereas the stock unittest method only has >>> one frame, the relevant line in the user's code. How can I apply this >>> frame-hiding behaviour to my own method? >> >> Move MyTestCase in a separate module and define a global variable >> >> __unittest = True >> > Hum, is it documented somewhere? I can't find it in the doc. Also, I'm > curious to know what kind of magic it's using. I took advantage of the fact that Python is open source and had a look into the source code ;) $ cd /usr/lib/python2.7/unittest $ grep frame *.py -C2 ... result.py- result.py-def _is_relevant_tb_level(self, tb): result.py:return '__unittest' in tb.tb_frame.f_globals result.py- ... $ grep _is_relevant_tb_level *.py -C5 result.py- result.py-def _exc_info_to_string(self, err, test): result.py-"""Converts a sys.exc_info()-style tuple of values into a string.""" result.py-exctype, value, tb = err result.py-# Skip test runner traceback levels result.py:while tb and self._is_relevant_tb_level(tb): result.py-tb = tb.tb_next result.py- ... And so on. I actually used an editor, not grep -- but you get the idea. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to create a login screen using core python language without using any framework
Hi, you can write a simple wsgi app for that, and run it through simple server, for example. http://docs.python.org/library/wsgiref.html 05.10.2012 12:06 пользователь написал: > I need to develop a simple login page using Python language with two > fields and a button, like: > > Username, Password, Login > > I know there are some beautiful Python frameworks like > > Django, Grok, WebPy, TurboGears > > which support web development using Python, but mine is a basic > requirement consisting of only 3 screens (pages): > > * 1st page - Login page (Redirects to 2nd page when login button is > clicked) > * 2nd page - Page with records in the form of a list, with an option for > adding new records (Redirects to 3rd page when "Add Records" button is > clicked) > * 3rd page - Page with fields, which are saved as records for the list > on 2nd page (After entering details and clicking Submit) > > So, I have decided to develop the above functionality using Python > **without** using any framework, so that I can have flexibility as well as > write my own code. > > 1. Is it possible to create a login page using Python without using a > framework? > > 2. I haven't worked on web services and don't know the basics of web > development in Python. > > 3. If possible, can you provide me an example on how to create a login > page using Python and achieve the functionality described above? > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: final question: logging to stdout and updating files
On 04/10/2012 23:36, Prasad, Ramit wrote: Python is a product for Americans! ;) It should ensure America wins the Test Matchwait, do we even have a cricket team? ChrisA could have been talking rugby, your rugby union team isn't't too bad for a bunch of amateurs, some of whom had to take unpaid leave to play in the world cup. I don't think there's any rugby league sides in the USA. Then there's speedway and...? Optimization really is that important, folks! ChrisA may need to schedule surgical detongueing of his cheek Think we could get a group rate for c.l.p? I'm sure that with some appropriate grovelling the PSF could arrange this. Perhaps fly everybody to the UK for PyCon and get the surgery done on the NHS at the same time. Ramit -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to print html in python the normal way
Hi, Thanks for the reply. Apologies for my question not clear. Yes I am using django framework for it. - Regards Ashish -- http://mail.python.org/mailman/listinfo/python-list
Re: notmm is dead!
On Thursday, 4 October 2012 23:40:47 UTC+5:30, Etienne Robillard wrote: > Dear list, > > > > Due to lack of energy and resources i'm really sad to announce the removal of > notmm from pypi and bitbucket. I deleted > > also my account from bitbucket as it was not really useful for me. notmm will > continue to be accessible from my master > > site at http://gthc.org/dist/notmm until the server get down, as I cannot > find money to pay for the hosting of notmm.org, Can't you use Google Code? > > neither anyone to encourage the project so it can grow further. > > > > I have tried to develop a coherent extension for Django using the open source > model but I'm afraid to have been > > bitten by its failure to encourage a free market over one dictated by profit > and the use of cheap tricks to compete unfairly > > with perhaps too much openness. I always will also continue to love and use > free softwares but sadly it seems asking for a little > > fairness is too much asked to competitors dedicated in stealing and > subverting my work for their own advantages... > > > > I therefore refuse to continue any longer being mocked by competitors asking > excessive prices for having a broken Internet dictated by > > a few companies and decide the content I should be visiting. > > > > Shall you have anything you wish saying I'll be open to discuss further on > this list. I wish also to thanks the supporters > > of the project who have invested time and energy into my business and > dedication to the notmm project. > > > > Best wishes, > > > > Etienne > > > > -- > > Etienne Robillard > > Green Tea Hackers Club > > Fine Software Carpentry For The Rest Of Us! > > http://gthc.org/ > > [email protected] > > > > "If a free society cannot help the many who are poor, it cannot save the few > who are rich." -John F. Kennedy -- http://mail.python.org/mailman/listinfo/python-list
Re: sum function
On Friday, 5 October 2012 07:31:24 UTC+5:30, Mike wrote: > I agree with you, Ian. Thanks for all the help. Now I get the below error. > > > > File "test.py", line 17, in > > total = sum(float(col.value) for r in iter(next_r, None) for col in > r[0].columns.itervalues()) > > File "test.py", line 17, in > > total = sum(float(col.value) for r in iter(next_r, None) for col in > r[0].columns.itervalues()) > > > > Thanks You have missed the last line of the traceback (error) -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I hide my stack frames in a TestCase subclass?
Peter Otten scripsit : > Manuel Pégourié-Gonnard wrote: > >> Peter Otten scripsit : >> >>> __unittest = True >>> >> Hum, is it documented somewhere? I can't find it in the doc. Also, I'm >> curious to know what kind of magic it's using. > > I took advantage of the fact that Python is open source and had a look into > the source code ;) > Fair enough. However, there was an implied question in the "documented" part: can we rely on it? Isn't it considered an implementation detail (names starting with underscores)? > $ cd /usr/lib/python2.7/unittest > $ grep frame *.py -C2 > ... > result.py- > result.py-def _is_relevant_tb_level(self, tb): > result.py:return '__unittest' in tb.tb_frame.f_globals > result.py- > ... > > $ grep _is_relevant_tb_level *.py -C5 > result.py- > result.py-def _exc_info_to_string(self, err, test): > result.py-"""Converts a sys.exc_info()-style tuple of values into a > string.""" > result.py-exctype, value, tb = err > result.py-# Skip test runner traceback levels > result.py:while tb and self._is_relevant_tb_level(tb): > result.py-tb = tb.tb_next > result.py- > ... > > And so on. I actually used an editor, not grep -- but you get the idea. Sure, thanks. -- Manuel Pégourié-Gonnard - http://people.math.jussieu.fr/~mpg/ -- http://mail.python.org/mailman/listinfo/python-list
error bluetooth
the code is output the error of the ubuntu from bluetooth import * target_name = "My Phone" target_address = None nearby_devices = discover_devices() for address in nearby_devices: if target_name == lookup_name( address ): target_address = address break if target_address is not None: print "found target bluetooth device with address", target_address else: print "could not find target bluetooth device nearby" the error luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py Traceback (most recent call last): File "bluetooth.py", line 14, in from bluetooth import * File "/home/luca/py-temperature/py-temperature/bluetooth.py", line 19, in nearby_devices = discover_devices() NameError: name 'discover_devices' is not defined luca@luca-XPS-M1330:~/py-temperature/py-temperature$ it's a bug of the module? thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: + in regular expression
Cameron Simpson wrote:
> On 03Oct2012 21:17, Ian Kelly wrote:
>| On Wed, Oct 3, 2012 at 9:01 PM, contro opinion
>| wrote:
>| > why the "\s{6}+" is not a regular pattern?
>|
>| Use a group: "(?:\s{6})+"
>
> Yeah, it is probably a precedence issue in the grammar.
> "(\s{6})+" is also accepted.
It's about syntax, not precedence, but the documentation doesn't really
spell it out in full. Like most regex documentation it talks in woolly
terms about special characters rather than giving a formal syntax.
A regular expression element may be followed by a quantifier.
Quantifiers are '*', '+', '?', '{n}', '{n,m}' (and lazy quantifiers
'*?', '+?', '{n,m}?'). There's nothing in the regex language which says
you can follow an element with two quantifiers. Parentheses (grouping or
non-grouping) around a regex turn that regex into a single element which
is why you can then use another quantifier.
In bnf, I think Python's regexes would be somthing like:
re ::= union | simple-re
union ::= re | simple-re
simple-re ::= concatenation | basic-re
concatenation ::= simple-re basic-re
basic-re ::= element | element quantifier
element ::= group | nc-group | "." | "^" | "$" | char | charset
quantifier = "*" | "+" | "?" | "{" NUMBER "}" | "{" NUMBER "," NUMBER
"}" |"*?" | "+?" | "{" NUMBER "," NUMBER "}?"
group ::= "(" re ")"
nc-group ::= "(?:" re ")"
char = | "\"
... and so on. I didn't include charsets or all the (?...) extensions or
special sequences.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: How can I hide my stack frames in a TestCase subclass?
Manuel Pégourié-Gonnard wrote: > However, there was an implied question in the "documented" part: can > we rely on it? Isn't it considered an implementation detail (names > starting with underscores)? "Not documented" was my implied answer. I think you have a valid use case, though, so you could make a feature request for an official way to hide stack frames on the bugtracker http://bugs.python.org or the python-ideas mailing list. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to create a login screen using core python language without using any framework
On 5/10/12 10:03:56, [email protected] wrote: > I need to develop a simple login page using Python language with > two fields and a button, like: > > Username, Password, Login > > I know there are some beautiful Python frameworks like > > Django, Grok, WebPy, TurboGears > > which support web development using Python, but mine is a basic > requirement consisting of only 3 screens (pages): > > * 1st page - Login page (Redirects to 2nd page when login button > is clicked) > * 2nd page - Page with records in the form of a list, with an > option for adding new records (Redirects to 3rd page when "Add > Records" button is clicked) > * 3rd page - Page with fields, which are saved as records for > the list on 2nd page (After entering details and clicking Submit) Implementing your application using any of those frameworks you mentioned, would be easy. > So, I have decided to develop the above functionality using Python > **without** using any framework, so that I can have flexibility as > well as write my own code. This is a bad idea. You'll get much more flexibility using an existing framework then you'd ever achieve by reinventing the wheel on your own. Especially if you have no experience in this field. > 1. Is it possible to create a login page using Python without > using a framework? Yes. But it's a lot of work. You'd effectively be rewriting all the functionality you'd get for free with a framework. And it wouldn't be as flexible, because frameworks can flex in directions that you didn't think of. > 2. I haven't worked on web services and don't know the basics of > web development in Python. In that case, your chances of success are fairly slim. > 3. If possible, can you provide me an example on how to create a > login page using Python and achieve the functionality described > above? The frameworks you mentioned earlier come with tutorials. These tutorials contain such examples. You should really use an existing framework. Once you're aware of how much functionality you get out of a framework (any of them), you wouldn't dream of rewriting all that functionality on your own. Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: error bluetooth
Am 05.10.2012 10:51, schrieb Luca Sanna: the code is output the error of the ubuntu from bluetooth import * [...] nearby_devices = discover_devices() [...] the error luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py Traceback (most recent call last): File "bluetooth.py", line 14, in from bluetooth import * File "/home/luca/py-temperature/py-temperature/bluetooth.py", line 19, in nearby_devices = discover_devices() NameError: name 'discover_devices' is not defined The module "bluetooth" doesn't export any function called discover_devices(). You could try "dir(bluetooth)" or "help(bluetooth)" (do that from an interactive prompt) to find out what is in there. I don't know why you expect such a function there, if it is mentioned in the documentation or example code that would be a bug. Uli -- http://mail.python.org/mailman/listinfo/python-list
Re: error bluetooth
On 10/05/2012 04:51 AM, Luca Sanna wrote: > the code is output the error of the ubuntu > > from bluetooth import * > > target_name = "My Phone" > target_address = None > > nearby_devices = discover_devices() > > for address in nearby_devices: > if target_name == lookup_name( address ): > target_address = address > break > > if target_address is not None: > print "found target bluetooth device with address", target_address > else: > print "could not find target bluetooth device nearby" > > the error > > luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py > Traceback (most recent call last): > File "bluetooth.py", line 14, in > from bluetooth import * > File "/home/luca/py-temperature/py-temperature/bluetooth.py", line 19, in > > nearby_devices = discover_devices() > NameError: name 'discover_devices' is not defined > luca@luca-XPS-M1330:~/py-temperature/py-temperature$ > > it's a bug of the module? thanks Perhaps you named your script bluetooth.py, and thus masked the module bluetooth.py. Pick a different name for your own sources. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: notmm is dead!
No. All past notmm licenses were and still ARE ISC licensed. The license fee is simply because I'm shifting into commercial license for new releases, including the newer 0.4.5 version... Pypi was not the authority source for notmm and neither anyone can claim the license was left blank, thats once again a form of plagiarism. Shall anyone is really serious about supporting the work i did then he'll want to pay a minimal fee to get the proper license rights and can contact me off-list if he want to fork a branch to github of google code. Thanks, Etienne On Thu, 04 Oct 2012 20:39:55 -0600 Michael Torrie wrote: > On 10/04/2012 05:13 PM, Etienne Robillard wrote: > > Thanks, but I tried all that and don't have much energy for continuing. If > > you're > > serious about open source then maybe you can forward the thread to > > django-developers > > and get some fundings to pay for a minimalistic fee to get the project > > maintained > > by someone else, otherwise I'd prefer sticking with more profitable > > activities. > > Nothing in the existing license prevents someone from taking the latest > source and posting it back on Pypi as an unmaintained package. Isn't > that correct? > > What are you referring to when you say "minimalistic fee." Would this > be a fee you require for transferring copyright assignment? I know of > no fee necessary for a new maintainer to take over should one wish to. > Copyright assignment is not strictly necessary. > > -- > http://mail.python.org/mailman/listinfo/python-list -- Etienne Robillard Green Tea Hackers Club Fine Software Carpentry For The Rest Of Us! http://gthc.org/ [email protected] -- http://mail.python.org/mailman/listinfo/python-list
When was the last time you did something for the first time?
What do you want to talk about today? -- http://mail.python.org/mailman/listinfo/python-list
Re: When was the last time you did something for the first time?
Micro$oft :) On Fri, 5 Oct 2012 04:03:52 -0700 (PDT) The Matchmaker wrote: > What do you want to talk about today? > -- > http://mail.python.org/mailman/listinfo/python-list -- Etienne Robillard Green Tea Hackers Club Fine Software Carpentry For The Rest Of Us! http://gthc.org/ [email protected] -- http://mail.python.org/mailman/listinfo/python-list
Re: error bluetooth
On 5/10/12 10:51:42, Luca Sanna wrote: > from bluetooth import * [..] > luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py When you say "from bluetooth import *", Python will find a file name "bluetooth.py" and import stuff from that file. Since your script happens to be named "bluetooth.py", Python will import your script, thinking it is a module. > it's a bug of the module? You've chosen the wrong file name. Rename your script. Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading properties file in Python, except using ConfigParser()
[email protected] wrote: >How to read properties file in Python? I found ConfigParser() but it has a >'section' limitation, so looking for other alternatives. Have a look at PyYAML. Best regards, Günther -- http://mail.python.org/mailman/listinfo/python-list
Re: error bluetooth
Il giorno venerdì 5 ottobre 2012 13:33:14 UTC+2, Hans Mulder ha scritto: > On 5/10/12 10:51:42, Luca Sanna wrote: > > > > > from bluetooth import * > > > > [..] > > > > > luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py > > > > When you say "from bluetooth import *", Python will find a file > > name "bluetooth.py" and import stuff from that file. Since your > > script happens to be named "bluetooth.py", Python will import > > your script, thinking it is a module. > > > > > it's a bug of the module? > > > > You've chosen the wrong file name. Rename your script. > > > > > > Hope this helps, > > > > -- HansM i'm sorry, it's ok the rename file in bt.py how do I send a ping in bluetooth? because android phones are not always visible. I can not find the ping command thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Coexistence of Python 2.x and 3.x on same OS
On 10/1/2012 1:32 PM, Dennis Lee Bieber wrote: On Sun, 30 Sep 2012 23:06:04 -0400, Edward Diener declaimed the following in gmane.comp.python.general: My thought is a program distributed by Python which finds the versions of Python on an OS, lets the end-user choose which version should be invoked when Python is invoked, and does whatever is necessary to make that version the default version. Which wouldn't be usable on any system that has to boot/process unattended, and run's Python scripts for configuration set-up. I can understand that but my use of Python on Windows is not that case. I simply want to be able to choose which version of Python runs when it is invoked, when I have multiple versions installed. Surely that is a very common case for end-users running 'python' or invoking some script which is associated with python. Making a version "default" pretty much means being able to rewrite the PATH environment variable... And I've seen too many messes made by some software already (including once having two generations of Python showing up in one PATH!) The PATH environment is constantly changing whether in Linux or Windows. Claiming that this is too dangerous" is silly. -- http://mail.python.org/mailman/listinfo/python-list
Re: Coexistence of Python 2.x and 3.x on same OS
On 10/1/2012 12:02 PM, Alister wrote: On Sun, 30 Sep 2012 15:14:17 -0400, Edward Diener wrote: Has there been any official software that allows both the Python 2.x and 3.x releases to coexist on the same OS so that the end-user can easily switch between them when invoking Python scripts after each has been installed to their own directories/folders ? I know of some unoffical solutions, but they require lots of tweaks. Given the vagaries of the different OSs on which Python can run I am hoping for some offical solution which will work on any of the most popular OSs ( Windows, Linux, Mac ). The situation is so confusing on Windows, where the file associations, registry entries, and other internal software which allows a given Python release to work properly when invoking Python is so complicated, that I have given up on trying to install more than one Python release and finding a relaible, foolproof way of switching between them. So although I would like to use the latest 3.x series on Windows I have decide to stick with the latest 2.x series instead because much software using Python does not support 3.x yet. on my fedora system it was a simple matter of:- #> yum install python3 to use python 3 i specify it in my shebang line #!/usr/bun/env python3 Simple Not sure about Windoze though (Although from memory the install asks where to install so should not be a major issue) Windows installs of Python do not distinguish releases by Pythonx(.x) but just install different versions of Python in different directories. However one can make links to the different versions based on their release numbers, and that would allow a shebang line work if it was supported. -- http://mail.python.org/mailman/listinfo/python-list
Re: Coexistence of Python 2.x and 3.x on same OS
On 9/30/2012 3:38 PM, Andrew Berg wrote: On 2012.09.30 14:14, Edward Diener wrote: The situation is so confusing on Windows, where the file associations, registry entries, and other internal software which allows a given Python release to work properly when invoking Python is so complicated, that I have given up on trying to install more than one Python release and finding a relaible, foolproof way of switching between them. So although I would like to use the latest 3.x series on Windows I have decide to stick with the latest 2.x series instead because much software using Python does not support 3.x yet. http://www.python.org/dev/peps/pep-0397/ Unix-based OSes should already obey the shebang line, and on Windows, there's py.exe in 3.3 that will launch the intended version based on that shebang line. While I was using the alpha/beta versions of 3.3, I had no problems invoking either 3.2 or 3.3 with the shebang line on Windows. Thanks ! I will get this and hopefully it will do what I want. -- http://mail.python.org/mailman/listinfo/python-list
Re: Coexistence of Python 2.x and 3.x on same OS
On 05/10/2012 13:15, Edward Diener wrote: On 10/1/2012 12:02 PM, Alister wrote: On Sun, 30 Sep 2012 15:14:17 -0400, Edward Diener wrote: Has there been any official software that allows both the Python 2.x and 3.x releases to coexist on the same OS so that the end-user can easily switch between them when invoking Python scripts after each has been installed to their own directories/folders ? I know of some unoffical solutions, but they require lots of tweaks. Given the vagaries of the different OSs on which Python can run I am hoping for some offical solution which will work on any of the most popular OSs ( Windows, Linux, Mac ). The situation is so confusing on Windows, where the file associations, registry entries, and other internal software which allows a given Python release to work properly when invoking Python is so complicated, that I have given up on trying to install more than one Python release and finding a relaible, foolproof way of switching between them. So although I would like to use the latest 3.x series on Windows I have decide to stick with the latest 2.x series instead because much software using Python does not support 3.x yet. on my fedora system it was a simple matter of:- #> yum install python3 to use python 3 i specify it in my shebang line #!/usr/bun/env python3 Simple Not sure about Windoze though (Although from memory the install asks where to install so should not be a major issue) Windows installs of Python do not distinguish releases by Pythonx(.x) but just install different versions of Python in different directories. However one can make links to the different versions based on their release numbers, and that would allow a shebang line work if it was supported. Please read this http://www.python.org/dev/peps/pep-0397/ and let us know whether or not it fits your needs on Windows. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: When was the last time you did something for the first time?
On Friday, 5 October 2012 16:33:52 UTC+5:30, The Matchmaker wrote: > What do you want to talk about today? Nothing. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to create a login screen using core python language without using any framework
On Fri, Oct 5, 2012 at 5:29 AM, Hans Mulder wrote: > On 5/10/12 10:03:56, [email protected] wrote: >> I need to develop a simple login page using Python language with >> two fields and a button, like: >> >> Username, Password, Login >> >> I know there are some beautiful Python frameworks like >> >> Django, Grok, WebPy, TurboGears >> >> which support web development using Python, but mine is a basic >> requirement consisting of only 3 screens (pages): >> >> * 1st page - Login page (Redirects to 2nd page when login button >> is clicked) >> * 2nd page - Page with records in the form of a list, with an >> option for adding new records (Redirects to 3rd page when "Add >> Records" button is clicked) >> * 3rd page - Page with fields, which are saved as records for >> the list on 2nd page (After entering details and clicking Submit) > > Implementing your application using any of those frameworks you > mentioned, would be easy. > >> So, I have decided to develop the above functionality using Python >> **without** using any framework, so that I can have flexibility as >> well as write my own code. > > This is a bad idea. You'll get much more flexibility using > an existing framework then you'd ever achieve by reinventing > the wheel on your own. Especially if you have no experience > in this field. > >> 1. Is it possible to create a login page using Python without >> using a framework? > > Yes. > > But it's a lot of work. You'd effectively be rewriting all > the functionality you'd get for free with a framework. And > it wouldn't be as flexible, because frameworks can flex in > directions that you didn't think of. > >> 2. I haven't worked on web services and don't know the basics of >> web development in Python. > > In that case, your chances of success are fairly slim. > >> 3. If possible, can you provide me an example on how to create a >> login page using Python and achieve the functionality described >> above? > > The frameworks you mentioned earlier come with tutorials. > These tutorials contain such examples. > > You should really use an existing framework. Once you're > aware of how much functionality you get out of a framework > (any of them), you wouldn't dream of rewriting all that > functionality on your own. I totally agree about using a framework. You say you want a 'simple' 3 page website. Why do you think it is simple? You say you don't have any skills at creating websites with python. From your description, you will need to build a directory of entries, a form, and attach it to a database, so that means you also need to understand sql (or something!). You need to display individual records I imagine. Do you need to edit them after they are created? How are you going to manage the accounts? Will you create them? Will you let the visitor create an account? Where will you store the account information? Do different accounts have different permissions? If you install django (for instance), go through the online tutorials in about 2 hours, you could probably build your specification in a day. Even if you have problems there is an active django mailing list to ask specific questions. I haven't tried the other frameworks, but there might be similar help available for them. -- Joel Goldstick -- http://mail.python.org/mailman/listinfo/python-list
Re: final question: logging to stdout and updating files
On Thursday, 4 October 2012 19:30:26 UTC+5:30, Steven D'Aprano wrote: > On Thu, 04 Oct 2012 06:34:28 -0700, Ramchandra Apte wrote: > > > > > "Optimize code always even if it causes bugs" - Ramchandra Apte, 2001- > > > > Well, you've just added yourself into my list of people whose advice > > should always be ignored. > > > > That is *terrible* advice. But if you insist on following it, you can > > optimize *any* Python program to this: > > > > # === start code === > > pass # this line is optional > > # === end code === > > > > > > There you go. The most heavily optimized, fastest Python program in > > existence. Sure, it has a few bugs, but boy is it fast!!! > > > > > > -- > > Steven Please disclose the list of people. This email is subject to important disclosures available at loobafoobajo.ke/legal.html LOOBA FOOBA JOKE COMPANY MAKES NO WARRANTIES ABOUT THIS EMAIL Read at your risk - you may die from reading this email. ;-P -- http://mail.python.org/mailman/listinfo/python-list
Re: sum function
On Thursday, October 4, 2012 4:52:50 PM UTC-4, Mike wrote:
> Hi All,
>
>
>
> I am new to python and am getting the data from hbase.
>
> I am trying to do sum on the column as below
>
>
>
>
>
> scanner = client.scannerOpenWithStop("tab", "10", "1000", ["cf:col1"])
>
> total = 0.0
>
> r = client.scannerGet(scanner)
>
> while r:
>
> for k in (r[0].columns):
>
> total += float(r[0].columns[k].value)
>
> r = client.scannerGet(scanner)
>
>
>
> print total
>
>
>
> Do you know of better (faster) way to do sum?
>
>
>
> Any thoughts please?
>
>
>
> Thanks
Sorry about that. Here you go
Traceback (most recent call last):
File "test.py", line 17, in
total = sum(float(col.value) for r in iter(next_r, None) for col in
r[0].columns.itervalues())
File "test.py", line 17, in
total = sum(float(col.value) for r in iter(next_r, None) for col in
r[0].columns.itervalues())
IndexError: list index out of range
--
http://mail.python.org/mailman/listinfo/python-list
Re: sum function
On Friday, 5 October 2012 19:09:15 UTC+5:30, Mike wrote:
> On Thursday, October 4, 2012 4:52:50 PM UTC-4, Mike wrote:
>
> > Hi All,
>
> >
>
> >
>
> >
>
> > I am new to python and am getting the data from hbase.
>
> >
>
> > I am trying to do sum on the column as below
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > scanner = client.scannerOpenWithStop("tab", "10", "1000", ["cf:col1"])
>
> >
>
> > total = 0.0
>
> >
>
> > r = client.scannerGet(scanner)
>
> >
>
> > while r:
>
> >
>
> > for k in (r[0].columns):
>
> >
>
> > total += float(r[0].columns[k].value)
>
> >
>
> > r = client.scannerGet(scanner)
>
> >
>
> >
>
> >
>
> > print total
>
> >
>
> >
>
> >
>
> > Do you know of better (faster) way to do sum?
>
> >
>
> >
>
> >
>
> > Any thoughts please?
>
> >
>
> >
>
> >
>
> > Thanks
>
>
>
> Sorry about that. Here you go
>
>
>
> Traceback (most recent call last):
>
> File "test.py", line 17, in
>
> total = sum(float(col.value) for r in iter(next_r, None) for col in
> r[0].columns.itervalues())
>
> File "test.py", line 17, in
>
> total = sum(float(col.value) for r in iter(next_r, None) for col in
> r[0].columns.itervalues())
>
> IndexError: list index out of range
the variable "r" is an empty list
--
http://mail.python.org/mailman/listinfo/python-list
Re: sum function
On Friday, October 5, 2012 9:41:44 AM UTC-4, Ramchandra Apte wrote:
> On Friday, 5 October 2012 19:09:15 UTC+5:30, Mike wrote:
>
> > On Thursday, October 4, 2012 4:52:50 PM UTC-4, Mike wrote:
>
> >
>
> > > Hi All,
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > I am new to python and am getting the data from hbase.
>
> >
>
> > >
>
> >
>
> > > I am trying to do sum on the column as below
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > scanner = client.scannerOpenWithStop("tab", "10", "1000", ["cf:col1"])
>
> >
>
> > >
>
> >
>
> > > total = 0.0
>
> >
>
> > >
>
> >
>
> > > r = client.scannerGet(scanner)
>
> >
>
> > >
>
> >
>
> > > while r:
>
> >
>
> > >
>
> >
>
> > > for k in (r[0].columns):
>
> >
>
> > >
>
> >
>
> > > total += float(r[0].columns[k].value)
>
> >
>
> > >
>
> >
>
> > > r = client.scannerGet(scanner)
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > print total
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Do you know of better (faster) way to do sum?
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Any thoughts please?
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > >
>
> >
>
> > > Thanks
>
> >
>
> >
>
> >
>
> > Sorry about that. Here you go
>
> >
>
> >
>
> >
>
> > Traceback (most recent call last):
>
> >
>
> > File "test.py", line 17, in
>
> >
>
> > total = sum(float(col.value) for r in iter(next_r, None) for col in
> > r[0].columns.itervalues())
>
> >
>
> > File "test.py", line 17, in
>
> >
>
> > total = sum(float(col.value) for r in iter(next_r, None) for col in
> > r[0].columns.itervalues())
>
> >
>
> > IndexError: list index out of range
>
>
>
> the variable "r" is an empty list
Here is the actual code.
scanner = client.scannerOpenWithStop("tab", "10", "1000", ["cf:col1"])
next_r = functools.partial(client.scannerGet, scanner)
total = sum(float(col.value) for r in iter(next_r, None) for col in
r[0].columns.itervalues())
Scanner does have rows.
Are we missing something please?
Thanks
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to call python script from web.
On Fri, Oct 5, 2012 at 9:59 AM, Mike wrote: > Hi, > > I can call the php script from browser assuming apache web server exists. > > How can I call the python script like php script? > > Any thought? > > Thanks > -- > http://mail.python.org/mailman/listinfo/python-list A popular way for apache is to use mod_wsgi. http://code.google.com/p/modwsgi/ -- Joel Goldstick -- http://mail.python.org/mailman/listinfo/python-list
Re: How to create a login screen using core python language without using any framework
On 12-10-05 06:11 AM, Joel Goldstick wrote: I totally agree about using a framework. You say you want a 'simple' 3 page website. Why do you think it is simple? You say you don't have any skills at creating websites with python. From your description, you will need to build a directory of entries, a form, and attach it to a database, so that means you also need to understand sql (or something!). You need to display individual records I imagine. Do you need to edit them after they are created? How are you going to manage the accounts? Will you create them? Will you let the visitor create an account? Where will you store the account information? Do different accounts have different permissions? Not to mention security. Frameworks like Django provide protection against things like: * CSRF (Cross Site Request Forgery) * XSS ((X)Cross Site Scripting) * SQL injection As well as others. For a comprehensive list of protection that Django offers, check out https://docs.djangoproject.com/en/dev/topics/security/. -- Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list
Re: notmm is dead!
On 10/05/2012 04:43 AM, Etienne Robillard wrote: > No. All past notmm licenses were and still ARE ISC licensed. The license fee > is simply because I'm shifting into commercial license for new releases, > including > the newer 0.4.5 version... Pypi was not the authority source for notmm and > neither anyone can claim the license was left blank, thats once again a form > of plagiarism. > > Shall anyone is really serious about supporting the work i did then he'll > want to pay a minimal fee to get > the proper license rights and can contact me off-list if he want to fork a > branch > to github of google code. Someone certainly could fork any past ISC version and proceed from there. That is simply my point. Without any license fees and without any accusation of "plagiarism." Indeed it wouldn't be plagiarism because your name would still be on it, and copyright assigned to you. I don't know what you are talking about with the plagiarism thing. If there indeed was a tarball out there with an empty license file all that would do would be to prevent the downloader from legally doing *anything* with the file. That's all the original poster was saying. We're just trying to be clear on the terms here, not accusing you of anything, nor trying to denigrate all your hard work. -- http://mail.python.org/mailman/listinfo/python-list
Re: Re: + in regular expression
On 10/05/2012 04:23 AM, Duncan Booth wrote:
A regular expression element may be followed by a quantifier.
Quantifiers are '*', '+', '?', '{n}', '{n,m}' (and lazy quantifiers
'*?', '+?', '{n,m}?'). There's nothing in the regex language which says
you can follow an element with two quantifiers.
In fact, *you* did -- the first sentence of that paragraph! :-)
\s is a regex, so you can follow it with a quantifier and get \s{6}.
That's also a regex, so you should be able to follow it with a quantifier.
I can understand that you can create a grammar that excludes it. I'm
actually really interested to know if anyone knows whether this was a
deliberate decision and, if so, what the reason is. (And if not --
should it be considered a (low priority) bug?)
Was it because such patterns often reveal a mistake? Because "\s{6}+"
has other meanings in different regex syntaxes and the designers didn't
want confusion? Because it was simpler to parse that way? Because the
"hey you recognize regular expressions by converting it to a finite
automaton" story is a lie in most real-world regex implementations (in
part because they're not actually regular expressions) and repeated
quantifiers cause problems with the parsing techniques that actually get
used?
Evan
--
http://mail.python.org/mailman/listinfo/python-list
Re: notmm is dead!
On Oct 4, 2012 6:56 PM, "Etienne Robillard" wrote: > > You probably have a old tarball or something... Not unless you've replaced it since I made my post, as I had just downloaded it to check the license. -- http://mail.python.org/mailman/listinfo/python-list
Re: + in regular expression
On 10/05/2012 10:27 AM, Evan Driscoll wrote:
On 10/05/2012 04:23 AM, Duncan Booth wrote:
A regular expression element may be followed by a quantifier.
Quantifiers are '*', '+', '?', '{n}', '{n,m}' (and lazy quantifiers
'*?', '+?', '{n,m}?'). There's nothing in the regex language which says
you can follow an element with two quantifiers.
In fact, *you* did -- the first sentence of that paragraph! :-)
\s is a regex, so you can follow it with a quantifier and get \s{6}.
That's also a regex, so you should be able to follow it with a
quantifier.
OK, I guess this isn't true... you said a "regular expression *element*"
can be followed by a quantifier. I just took what I usually see as part
of a regular expression and read into your post something it didn't
quite say. Still, the rest of mine applies.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
RE: When was the last time you did something for the first time?
I learn trigonometry -Original Message- From: Ramchandra Apte [mailto:[email protected]] Sent: Friday, October 05, 2012 8:03 AM To: [email protected] Subject: Re: When was the last time you did something for the first time? On Friday, 5 October 2012 16:33:52 UTC+5:30, The Matchmaker wrote: > What do you want to talk about today? Nothing. -- http://mail.python.org/mailman/listinfo/python-list
Re: notmm is dead!
On Fri, 5 Oct 2012 09:29:39 -0600 Ian Kelly wrote: > On Oct 4, 2012 6:56 PM, "Etienne Robillard" wrote: > > > > You probably have a old tarball or something... > > Not unless you've replaced it since I made my post, as I had just > downloaded it to check the license. The 0.4.4 release is old, however, so you might really got a wrong tarball. :-) Cheers, Etienne -- Etienne Robillard Green Tea Hackers Club Fine Software Carpentry For The Rest Of Us! http://gthc.org/ [email protected] -- http://mail.python.org/mailman/listinfo/python-list
Re: + in regular expression
On 2012-10-05 16:27, Evan Driscoll wrote:
On 10/05/2012 04:23 AM, Duncan Booth wrote:
A regular expression element may be followed by a quantifier.
Quantifiers are '*', '+', '?', '{n}', '{n,m}' (and lazy quantifiers
'*?', '+?', '{n,m}?'). There's nothing in the regex language which says
you can follow an element with two quantifiers.
In fact, *you* did -- the first sentence of that paragraph! :-)
\s is a regex, so you can follow it with a quantifier and get \s{6}.
That's also a regex, so you should be able to follow it with a quantifier.
I can understand that you can create a grammar that excludes it. I'm
actually really interested to know if anyone knows whether this was a
deliberate decision and, if so, what the reason is. (And if not --
should it be considered a (low priority) bug?)
Was it because such patterns often reveal a mistake? Because "\s{6}+"
has other meanings in different regex syntaxes and the designers didn't
want confusion? Because it was simpler to parse that way? Because the
"hey you recognize regular expressions by converting it to a finite
automaton" story is a lie in most real-world regex implementations (in
part because they're not actually regular expressions) and repeated
quantifiers cause problems with the parsing techniques that actually get
used?
You rarely want to repeat a repeated element. It can also result in
catastrophic
backtracking unless you're _very_ careful.
In many other regex implementations (including mine), "*+", "*+" and
"?+" are possessive quantifiers, much as "??", "*?" and "??" are lazy
quantifiers.
You could, of course, ask why adding "?" after a quantifier doesn't
make it optional, e.g. why r"\s{6}?" doesn't mean the same as
r"(?:\s{6})?", or why r"\s{0,6}?" doesn't mean the same as
r"(?:\s{0,6})?".
--
http://mail.python.org/mailman/listinfo/python-list
Re: [fcgi.py] Force cache upgrade?
Gilles wrote: > On Fri, 28 Sep 2012 23:57:14 +0200, Gilles wrote: >> I guess the FastCGI server (Flup) only updates its cache every so >> often. Do I need to type a command to force Flup to recompile the >> Python script? > > Turns out that, yes, mod_fcgid is configured to reload a script only > after some time or some number of hits, Well, that's the whole point of using FastCGI: Have a long-running process for better performance. Ciao, Michael. -- http://mail.python.org/mailman/listinfo/python-list
instance.attribute lookup
There is a StackOverflow question [1] that points to this on-line book [2] which has a five-step sequence for looking up attributes: > When retrieving an attribute from an object (print > objectname.attrname) Python follows these steps: > > 1. If attrname is a special (i.e. Python-provided) attribute for > objectname, return it. > > 2. Check objectname.__class__.__dict__ for attrname. If it exists and > is a data-descriptor, return the descriptor result. Search all bases > of objectname.__class__ for the same case. > > 3. Check objectname.__dict__ for attrname, and return if found. If > objectname is a class, search its bases too. If it is a class and a > descriptor exists in it or its bases, return the descriptor result. > > 4. Check objectname.__class__.__dict__ for attrname. If it exists and > is a non-data descriptor, return the descriptor result. If it exists, > and is not a descriptor, just return it. If it exists and is a data > descriptor, we shouldn't be here because we would have returned at > point 2. Search all bases of objectname.__class__ for same case. > > 5. Raise AttributeError I'm thinking step 1 is flat-out wrong and doesn't exist. Does anybody know otherwise? ~Ethan~ [1] http://stackoverflow.com/q/10536539/208880 [2] http://www.cafepy.com/article/python_attributes_and_methods/ch01s05.html -- http://mail.python.org/mailman/listinfo/python-list
Re: sum function
On 10/5/2012 9:47 AM, Mike wrote: On Friday, October 5, 2012 9:41:44 AM UTC-4, Ramchandra Apte wrote: On Friday, 5 October 2012 19:09:15 UTC+5:30, Mike wrote: On Thursday, October 4, 2012 4:52:50 PM UTC-4, Mike wrote: Hi All, I am new to python and am getting the data from hbase. If you want as many people as possible to read your posts, stop using a mail-agent and site that spits in the face of readers by doubling blank lines each iteration. Alternatives have been discussed previously. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
calendar from python to html
hi, I enter a calendar in an html page in each calendar day, I enter a time that is used by the program to perform actions with python What can I use to do this? thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: sum function
On Fri, Oct 5, 2012 at 7:39 AM, Mike wrote: > Sorry about that. Here you go > > Traceback (most recent call last): > File "test.py", line 17, in > total = sum(float(col.value) for r in iter(next_r, None) for col in > r[0].columns.itervalues()) > File "test.py", line 17, in > total = sum(float(col.value) for r in iter(next_r, None) for col in > r[0].columns.itervalues()) > IndexError: list index out of range Maybe the sentinel value is not None as I assumed, and it's overrunning the end of the data? What does client.scannerGet return when there is no more data? -- http://mail.python.org/mailman/listinfo/python-list
Re: Are ABCs an anti-pattern?
On Tue, Oct 02, 2012 at 07:23:05AM -0700, Demian Brecht wrote: > I don't use them anymore, but I'm curious about others opinions on this > list... I like them. In particular, I like that I can enumerate all the subclasses that happen to implement the ABC via the metaclass's __subclasses__() method. I also like that I can trust Python not to instantiate a subclass of an ABC unless it meets all the interface criteria I've stipulated. Both of these aspects make ABCs a great fit when your base classes will be subclassed by other users/libraries (i.e. that you have no control over). For example, I use them in a project of mine called Enversion in order to automatically generate command-line scaffolding with as little effort (programming/typing-wise as possible). The ABC stuff lives in 'evn.cli' and provides a set of generic classes for command-line tools. One of the command line tools that ships with Enversion is the 'evnadmin' command. Thanks to all the ABC scaffolding in the 'evn.cli/command' module, all I need to write is the following to get an 'evnadmin' command-line interface: from evn.cli import ( CLI, CommandLine, ) class AdminCommandLine(CommandLine): @property def commands_module(self): return evn.admin.commands class AdminCLI(CLI): @property def program_name(self): return 'evnadmin' @property def commandline_subclasses(self): return AdminCommandLine.__subclasses__() class DoctestCommandLine(AdminCommandLine): _quiet_ = True class DumpDefaultConfigCommandLine(AdminCommandLine): pass class DumpConfigCommandLine(AdminCommandLine): _conf_ = True class ShowConfigFileLoadOrderCommandLine(AdminCommandLine): _conf_ = True class DumpHookCodeCommandLine(AdminCommandLine): _conf_ = True _repo_ = True [snip] Running 'evnadmin' with no arguments yields this: % evnadmin Type 'evnadmin help' for help on a specific subcommand. Available subcommands: analyze create disable-remote-debug (drd) doctest dump-config (dc) dump-default-config (ddc) dump-hook-code (dhc) enable enable-remote-debug (erd) find-merges (fm) fix-hooks (fh) root-info (ri) run-hook (rh) show-config-file-load-order (scflo) show-repo-hook-status (srhs) show-repo-remote-debug-sessions (srrds) show-roots (sr) toggle-remote-debug (trd) version The scaffolding can generate all of that automatically thanks to the ability to enumerate __subclasses__() of a metaclass. The fact that Python will bomb out if a derived class doesn't implement all the required methods/properties is icing on the cake. When you are expecting other developers to leverage your ABCs, getting instant feedback when you forget to implement a required method/property is incredibly useful. It's definitely not a case of battling the design decisions made by the ABC author... Relevant Python files: https://github.com/tpn/enversion/blob/master/evn/cli.py https://github.com/tpn/enversion/blob/master/evn/admin/cli.py Regards, Trent. > Demian Brecht > @demianbrecht > http://demianbrecht.github.com > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: sum function
I added the print command. It prints [] when there is no data. Thanks -- http://mail.python.org/mailman/listinfo/python-list
RE: notmm is dead!
Steven D'Aprano wrote: > Sent: Thursday, October 04, 2012 7:22 PM > To: [email protected] > Subject: Re: notmm is dead! > > On Thu, 04 Oct 2012 14:10:46 -0400, Etienne Robillard wrote: > > > Dear list, > > > > Due to lack of energy and resources i'm really sad to announce the > > removal of notmm from pypi and bitbucket. > > Well that's just rude. Even if you don't intend to maintain the software > any more, why are you removing it from pypi? Since you say you are a fan > of Open Source software, just flag it as unmaintained and leave it for > somebody else to pick up. > > If you are going to abandon the project, release it on PyPI with a dual > MIT and GPL licence, and let it be taken over by somebody else. > > If you were looking for sympathy here, starting off by removing your > project from free hosting, then complaining that you can't pay for the > non-free hosting, was NOT the right way to do so. I might be misunderstanding, but I think Etienne wants money in exchange for letting someone else take over. > > By the way, the latest version of notmm (0.4.4) has an empty licence > file. No licence means that everyone using it is unlicenced and therefore > infringing your copyright. > > 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: sum function
Terry, I am not using the mail client. I am just posting on the site. Something wrong with this site. When you do individual reply, it does the double posting which it shouldn't. See "Ramachandra Apte's" reply. It is posted twice too. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: sum function
On Fri, Oct 5, 2012 at 2:03 PM, Mike wrote: > I added the print command. > > It prints [] when there is no data. Change "iter(next_r, None)" to "iter(next_r, [])" -- http://mail.python.org/mailman/listinfo/python-list
fmap(), "inverse" of Python map() function
http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html - Vasudev Ram www.dancingbison.com jugad2.blogspot.com twitter.com/vasudevram -- http://mail.python.org/mailman/listinfo/python-list
Re: sum function
On 10/05/2012 04:09 PM, Mike wrote: > Terry, > > I am not using the mail client. I am just posting on the site. And which site would that be (that you're using)? There are a few. I'm guessing you use google-groups. And all of them get gatewayed to the actual list, with differing numbers of bugs. I use email to access it directly. I solve one of the duplicate-message problems with google groups by automatically deleting any message addressed to google-groups. There are about 100 such messages each month. Another problem is that lots of these gateways post to both the newsgroup and to the python-list. > > Something wrong with this site. When you do individual reply, it does the > double posting which it shouldn't. See "Ramachandra Apte's" reply. It is > posted twice too. > > Thanks > > > -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: sum function
That worked, Ian. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: fmap(), "inverse" of Python map() function
On Fri, Oct 5, 2012 at 2:19 PM, vasudevram wrote: > > http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html Your fmap is a special case of reduce. def fmap(functions, argument): return reduce(lambda result, func: func(result), functions, argument) -- http://mail.python.org/mailman/listinfo/python-list
Re: fmap(), "inverse" of Python map() function
On Fri, Oct 5, 2012 at 3:31 PM, Ian Kelly wrote: > On Fri, Oct 5, 2012 at 2:19 PM, vasudevram wrote: >> >> http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html > > Your fmap is a special case of reduce. > > def fmap(functions, argument): > return reduce(lambda result, func: func(result), functions, argument) In a more functional style, you could also use reduce to compose the functions before applying them: def compose(f, g): return lambda x: f(g(x)) def fmap(functions): return reduce(compose, reversed(functions)) # Allowing you to then do: result = fmap(functions)(argument) Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Job
Looking for entry to mid level Python Developer for Contract job in New England. Let me know if you want to hear more. -- http://mail.python.org/mailman/listinfo/python-list
Executing untrusted scripts in a sandboxed environment
Hi all, I need to execute untrusted scripts in my Python application. To avoid security issues, I want to use a sandboxed environment. This means that the script authors have no access to the file system. They may only access objects, modules and classes that are "flagged" or "approved" for scripting. I read that I will not be able to do this with Python scripts. (See SandboxedPython page in the Python wiki [0] and several SE.com questions, e. g. [1].) So my question is: What is the best way to "embed" a script engine in a sandboxed environment that has access to the Python modules and classes that I provide? Thanks for your help. Best regards, Robin [0] http://wiki.python.org/moin/SandboxedPython [1] http://stackoverflow.com/questions/3068139/how-can-i-sandbox-python-in-pure-python -- http://mail.python.org/mailman/listinfo/python-list
Re: fmap(), "inverse" of Python map() function
On Fri, Oct 5, 2012 at 5:31 PM, Ian Kelly wrote: > On Fri, Oct 5, 2012 at 2:19 PM, vasudevram wrote: >> >> http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html > > Your fmap is a special case of reduce. So is map. def map(f, seq): return reduce( lambda rseq, newpre: rseq.append(f(newpre)) or rseq, seq, []) "X is a special case of reduce" is basically the same as saying "X can be implemented using a for loop". If it's meant as a complaint, it's a poor one. -- Devin -- http://mail.python.org/mailman/listinfo/python-list
Re: instance.attribute lookup
On Fri, 05 Oct 2012 10:39:53 -0700, Ethan Furman wrote: > There is a StackOverflow question [1] that points to this on-line book > [2] which has a five-step sequence for looking up attributes: > > > When retrieving an attribute from an object (print > > objectname.attrname) Python follows these steps: > > > > 1. If attrname is a special (i.e. Python-provided) attribute for > > objectname, return it. [...] > I'm thinking step 1 is flat-out wrong and doesn't exist. Does anybody > know otherwise? I'm thinking I don't even understand what step 1 means. What's a Python-provided attribute, and how is it different from other attributes? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: instance.attribute lookup
Steven D'Aprano wrote: On Fri, 05 Oct 2012 10:39:53 -0700, Ethan Furman wrote: There is a StackOverflow question [1] that points to this on-line book [2] which has a five-step sequence for looking up attributes: > When retrieving an attribute from an object (print > objectname.attrname) Python follows these steps: > > 1. If attrname is a special (i.e. Python-provided) attribute for > objectname, return it. [...] I'm thinking step 1 is flat-out wrong and doesn't exist. Does anybody know otherwise? I'm thinking I don't even understand what step 1 means. What's a Python-provided attribute, and how is it different from other attributes? Well, if /you/ don't understand it I feel a lot better about not understanding it either! :) Glad to know I'm not missing something (besides ESP, a crystal ball, and a mind-reader!) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: fmap(), "inverse" of Python map() function
On Fri, Oct 5, 2012 at 4:52 PM, Devin Jeanpierre wrote: > On Fri, Oct 5, 2012 at 5:31 PM, Ian Kelly wrote: >> On Fri, Oct 5, 2012 at 2:19 PM, vasudevram wrote: >>> >>> http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html >> >> Your fmap is a special case of reduce. > > So is map. I realize that. My point is that the function *feels* more like a variant of reduce than of map. > If it's meant as a complaint, it's a poor one. It's not. -- http://mail.python.org/mailman/listinfo/python-list
Re: instance.attribute lookup
Am 05.10.2012 19:39, schrieb Ethan Furman: > I'm thinking step 1 is flat-out wrong and doesn't exist. Does anybody > know otherwise? The answer is confusing and also wrong. For instance it ignores the existence of __slots__, metaclasses and the different lookup strategy of __special__ methods in old style and new style classes. -- http://mail.python.org/mailman/listinfo/python-list
Re: instance.attribute lookup
On Fri, Oct 5, 2012 at 11:39 AM, Ethan Furman wrote: > There is a StackOverflow question [1] that points to this on-line book [2] > which has a five-step sequence for looking up attributes: > >> When retrieving an attribute from an object (print >> objectname.attrname) Python follows these steps: >> >> 1. If attrname is a special (i.e. Python-provided) attribute for >> objectname, return it. >> >> 2. Check objectname.__class__.__dict__ for attrname. If it exists and >> is a data-descriptor, return the descriptor result. Search all bases >> of objectname.__class__ for the same case. >> >> 3. Check objectname.__dict__ for attrname, and return if found. If >> objectname is a class, search its bases too. If it is a class and a >> descriptor exists in it or its bases, return the descriptor result. >> >> 4. Check objectname.__class__.__dict__ for attrname. If it exists and >> is a non-data descriptor, return the descriptor result. If it exists, >> and is not a descriptor, just return it. If it exists and is a data >> descriptor, we shouldn't be here because we would have returned at >> point 2. Search all bases of objectname.__class__ for same case. >> >> 5. Raise AttributeError > > I'm thinking step 1 is flat-out wrong and doesn't exist. Does anybody know > otherwise? I think step 1 refers to looking up attributes like "foo.__class__" or "foo.__dict__" themselves. -- http://mail.python.org/mailman/listinfo/python-list
Re: instance.attribute lookup
On 06/10/2012 00:12, Ethan Furman wrote: Steven D'Aprano wrote: On Fri, 05 Oct 2012 10:39:53 -0700, Ethan Furman wrote: There is a StackOverflow question [1] that points to this on-line book [2] which has a five-step sequence for looking up attributes: > When retrieving an attribute from an object (print > objectname.attrname) Python follows these steps: > > 1. If attrname is a special (i.e. Python-provided) attribute for > objectname, return it. [...] I'm thinking step 1 is flat-out wrong and doesn't exist. Does anybody know otherwise? I'm thinking I don't even understand what step 1 means. What's a Python-provided attribute, and how is it different from other attributes? Well, if /you/ don't understand it I feel a lot better about not understanding it either! :) Glad to know I'm not missing something (besides ESP, a crystal ball, and a mind-reader!) ~Ethan~ My probably highly uneducated guess is that "Python-provided attribute" refers to double underscore names. YMMV by several trillion light years :) -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: fmap(), "inverse" of Python map() function
On Fri, Oct 5, 2012 at 7:24 PM, Ian Kelly wrote: > I realize that. My point is that the function *feels* more like a > variant of reduce than of map. > >> If it's meant as a complaint, it's a poor one. > > It's not. Fair enough all around. Sorry for misunderstanding. -- Devin -- http://mail.python.org/mailman/listinfo/python-list
Re: + in regular expression
On 05Oct2012 10:27, Evan Driscoll wrote:
| I can understand that you can create a grammar that excludes it. [...]
| Was it because such patterns often reveal a mistake?
For myself, I would consider that sufficient reason.
I've seen plenty of languages (C and shell, for example, though they
are not alone or egrarious) where a compiler can emit a syntax complaint
many lines from the actual coding mistake (in shell, an unclosed quote
or control construct is a common examplei; Python has the same issue
but mitigated by the indentation requirements which cut the occurence
down a lot).
Forbidding a common error by requiring a wordier workaround isn't
unreasonable.
| Because "\s{6}+"
| has other meanings in different regex syntaxes and the designers didn't
| want confusion?
I think Python REs are supposed to be Perl compatible; ISTR an opening
sentence to that effect...
| Because it was simpler to parse that way? Because the
| "hey you recognize regular expressions by converting it to a finite
| automaton" story is a lie in most real-world regex implementations (in
| part because they're not actually regular expressions) and repeated
| quantifiers cause problems with the parsing techniques that actually get
| used?
There are certainly constructs that can cause an exponential amount
of backtracking is misused. One could make a case for discouragement
(though not a case for forbidding them).
Just my 2c,
--
Cameron Simpson
The most annoying thing about being without my files after our disc crash was
discovering once again how widespread BLINK was on the web.
--
http://mail.python.org/mailman/listinfo/python-list
Problems building Python from hg trunk on Open SUSE
I haven't messed around with Python 3 recently, so decided to give it a whirl again. I cloned the trunk (cpython) and set about it. This is on an OpenSUSE 12.1 system. I configured like so: ./configure --prefix=/home/skipm/.linux-local and ran the usual "make ; make install". I'm a bit perplexed about how it is installed. Instead of installing shared objects in /home/skipm/.linux-local/lib/python3.4/lib-dynload they were installed in /home/skipm/.linux-local/lib64/python3.4/lib-dynload (note the "lib64" vs. "lib"). This would be fine, except sys.path doesn't include the "lib64" version of this path: % PYTHONPATH= PYTHONSTARTUP= ~/.linux-local/bin/python3.4 -S Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Python 3.4.0a0 (default:26200f535296, Oct 3 2012, 12:48:07) [GCC 4.4.6 [TWW]] on linux >>> import sys >>> sys.path ['', '', '/home/skipm/.linux-local/lib/python34.zip', '/home/skipm/.linux-local/lib/python3.4/', '/home/skipm/.linux-local/lib/python3.4/plat-linux', '/home/skipm/.linux-local/lib/lib-dynload'] I see the message about setting PYTHONHOME. (That happens to be bad advice as sys.prefix and sys.exec_prefix are identical in this case.) What I don't understand is why directories containing "lib64" are not in sys.path by default, given that that's where "make install" put things. GCC is as delivered by The Written Word. (This is a work computer. The powers that be settled on TWW awhile ago for packaging all open source software we use on Linux and Solaris, thus removing a headache from our support staff.) It is: % gcc --version gcc (GCC) 4.4.6 [TWW] Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The architecture looks like this: % uname -a Linux udesktop264 3.1.0-1.2-desktop #1 SMP PREEMPT Thu Nov 3 14:45:45 UTC 2011 (187dde0) x86_64 x86_64 x86_64 GNU/Linux I don't see anything in the output of "./configure --help" which relates to 64-bit install directories, though I do see some lines in config.log about guessing the architecture. Some cursory googling didn't turn up any promising web pages, and I didn't find anything in the various documentation files in the repo related to building Python. Any suggestions about how to resolve this would be appreciated. Thx, Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Coexistence of Python 2.x and 3.x on same OS
On 10/5/2012 5:32 PM, Dennis Lee Bieber wrote: On Fri, 05 Oct 2012 08:15:30 -0400, Edward Diener declaimed the following in gmane.comp.python.general: Windows installs of Python do not distinguish releases by Pythonx(.x) but just install different versions of Python in different directories. Really? E:\Python27>dir Volume in drive E is Data Volume Serial Number is 2626-D991 Directory of E:\Python27 08/28/2012 05:32 PM . 08/28/2012 05:32 PM .. 08/28/2012 02:11 PM DLLs 08/28/2012 05:43 PM Doc 08/28/2012 02:11 PM include 08/31/2012 04:58 PM Lib 08/28/2012 02:11 PM libs 08/28/2012 02:15 PM 108,255 matplotlib-wininst.log 08/28/2012 02:18 PM 4,169 MySQL-python-wininst.log 08/28/2012 02:15 PM98,498 numpy-wininst.log 08/28/2012 02:20 PM17,816 PIL-wininst.log 08/28/2012 03:29 PM 1,572 PyOpenGL-accelerate-wininst.log 08/28/2012 03:38 PM 3,009 pyserial-wininst.log 06/24/2011 12:38 PM27,136 python.exe 06/24/2011 12:38 PM27,136 python2.7.exe 06/24/2011 12:38 PM27,136 python2.exe 08/28/2012 05:32 PM90,943 PythonCard-wininst.log 06/24/2011 12:38 PM27,136 pythonw.exe 06/24/2011 12:38 PM27,136 pythonw2.7.exe 06/24/2011 12:38 PM27,136 pythonw2.exe That's, as you say, ActievState. The normal Python installer does not create a python2.7.exe etc. But of course I can create any links I want, so that's not really the problem. The major difficulty is that prior to invoking either "python" directly or a script with a normal Python file association, I want to be able to specify which version of Python should be invoked as the default without having to specifically invoke a partiocular version by typing 'python2.7 ...' or 'python3.3 ...' etc. 08/28/2012 02:15 PM 196,096 Removematplotlib.exe 08/28/2012 02:18 PM 196,096 RemoveMySQL-python.exe 08/28/2012 02:15 PM 196,096 Removenumpy.exe 08/28/2012 02:20 PM 196,096 RemovePIL.exe 08/28/2012 03:29 PM 196,096 RemovePyOpenGL-accelerate.exe 08/28/2012 03:38 PM 196,096 Removepyserial.exe 08/28/2012 05:32 PM61,440 RemovePythonCard.exe 08/28/2012 02:20 PM 196,096 Removereportlab.exe 08/28/2012 02:19 PM 196,096 Removescipy.exe 08/28/2012 05:29 PM 196,096 RemoveWConio.exe 08/28/2012 02:20 PM40,362 reportlab-wininst.log 08/28/2012 02:19 PM 159,420 scipy-wininst.log 08/28/2012 05:32 PM Scripts 08/28/2012 02:11 PM tcl 08/28/2012 02:11 PM Tools 11/28/2007 04:32 PM 258,352 unicows.dll 06/24/2011 12:38 PM49,664 w9xpopen.exe 08/28/2012 05:29 PM 891 WConio-wininst.log 28 File(s) 2,822,071 bytes 10 Dir(s) 148,557,684,736 bytes free E:\Python27> That's what was set up by a recent ActiveState installer (well, recent for me -- I'd still been using 2.5 three months ago) Yes, it IS in a version numbered directory, but there are copies of the executable named as plain python, pythonX, and pythonX.Y E:\Python27>cd %homepath% E:\UserData\Wulfraed\My Documents>python ActivePython 2.7.2.5 (ActiveState Software Inc.) based on Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. ^Z E:\UserData\Wulfraed\My Documents>python2.7 ActivePython 2.7.2.5 (ActiveState Software Inc.) based on Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. Granted, one would need to have each installation directory in the PATH, ordered such that the preferred version would be found first when using just "python". There is much more than just the PATH needed to change to have a different Python be the default. File associations also. I thnk there are more things too, but I know it has always been difficult on Windows to easily change which distribution is called when "python" is executed or some Python file association is executed. I welcome the new Python launcher for Windows mentioned but have not had a chance to use it and see how it works yet. I will try it this weekend and hopefully it will work well to solve the problem of having multiple Python installations installed on Windows at the same time, and being able to easily specify the one I want invoked. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems building Python from hg trunk on Open SUSE
In article , Skip Montanaro wrote: > I haven't messed around with Python 3 recently, so decided to give it > a whirl again. I cloned the trunk (cpython) and set about it. This > is on an OpenSUSE 12.1 system. I configured like so: [...] > Any suggestions about how to resolve this would be appreciated. It looks like you're running into the problems described in: http://bugs.python.org/issue15631 -- Ned Deily, [email protected] -- http://mail.python.org/mailman/listinfo/python-list
Re: notmm is dead!
Prasad, Ramit於 2012年10月6日星期六UTC+8上午4時06分31秒寫道: > Steven D'Aprano wrote: > > > Sent: Thursday, October 04, 2012 7:22 PM > > > To: [email protected] > > > Subject: Re: notmm is dead! > > > > > > On Thu, 04 Oct 2012 14:10:46 -0400, Etienne Robillard wrote: > > > > > > > Dear list, > > > > > > > > Due to lack of energy and resources i'm really sad to announce the > > > > removal of notmm from pypi and bitbucket. > > > > > > Well that's just rude. Even if you don't intend to maintain the software > > > any more, why are you removing it from pypi? Since you say you are a fan > > > of Open Source software, just flag it as unmaintained and leave it for > > > somebody else to pick up. > > > > > > If you are going to abandon the project, release it on PyPI with a dual > > > MIT and GPL licence, and let it be taken over by somebody else. > > > > > > If you were looking for sympathy here, starting off by removing your > > > project from free hosting, then complaining that you can't pay for the > > > non-free hosting, was NOT the right way to do so. > > > > I might be misunderstanding, but I think Etienne wants money in > > exchange for letting someone else take over. > > > > > > > > By the way, the latest version of notmm (0.4.4) has an empty licence > > > file. No licence means that everyone using it is unlicenced and therefore > > > infringing your copyright. > > > > > > > > > > > > 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. I think it is OK to have some string attatched in those open source projects. Nowadays the software industry is just like the perfume and prtinting and the audio-video entaertainment industry. The replication cost is so low. Don't forget the lawsuites in Facebook about the participants charged the founder in the courts. -- http://mail.python.org/mailman/listinfo/python-list
Re: calendar from python to html
Well, you need a web server, a webpage, a database (could just be a
file), a cgi script, and the datetime module. Optionally, you can use a
web framework like CherryPy or Django, which covers a lot of these by
itself.
I only know Python 2, but here are some examples:
A basic web server:
webdir = '.'
port = 80
import os, sys
from BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler
if len(sys.argv) > 1: webdir = sys.argv[1]
if len(sys.argv) > 2: port = int(sys.argv[2])
print 'webdir "%s", port %s' % (webdir, port)
#Windows only hack
if sys.platform[:3] == 'win':
CGIHTTPRequestHandler.have_popen2 = False
CGIHTTPRequestHandler.have_popen3 = False
sys.path.append('cgi-bin')
os.chdir(webdir)
srvraddr = ("", port)
srvrobj = HTTPServer(srvraddr, CGIHTTPRequestHandler)
srvrobj.serve_forever()
Start the script in the same directory as the cgi script and HTML.
Assuming you have a file that holds '1' time per date, you could
write a program to pickle and unpickle dictionaries that
are derived from form data:
import pickle
import cgi
file = open('dates.pkl', 'rb')
mydates = pickle.load(file)
file.close()
html = """
Schedule
"""
dates = ['april01', 'april02', 'april03', 'april04']
if form.has_key('submitted'):
newdates = {}
for d in dates:
if form.has_key(d):
newdates[d] = form[d].value
else:
newdates[d] = ''
mydates = newdates
output = open('dates.pkl', 'wb')
pickle.dump(mydates, output)
output.close()
else:
for d in dates:
if not mydates.has_key(d):
mydates[d] = ''
print html % mydates
Then you could write an additional program that runs
in the background or something:
import pickle
from datetime import date, datetime
mycode = 'print "Hello World!"'
file = open('dates.pkl', 'rb')
mydates = pickle.load(file)
file.close()
while True:
today = date.today()
if today.month == 4 and today.day == 01:
hour = datetime.time(datetime.now()).hour
min = datetime.time(datetime.now()).minute
if hour == int(mydates['april04'][0]) and min ==
int(mydates['april04'][-2:]):
exec mycode
_exec_ executes a Python string like a program. To execute an actual
python script use subprocess instead:
import subprocess
subprocess.call(["python", "myscript.py"])
Hope this helps.
On 10/05/2012 11:55 AM, Luca Sanna wrote:
hi,
I enter a calendar in an html page
in each calendar day, I enter a time that is used by the program to perform
actions with python
What can I use to do this?
thanks
--
http://mail.python.org/mailman/listinfo/python-list
Re: notmm is dead!
On 10/05/2012 07:43 PM, 8 Dihedral wrote: > I think it is OK to have some string attatched in those open source projects. What are you talking about? What "string?" > Nowadays the software industry is just like the perfume and prtinting > and the audio-video entaertainment industry. True > The replication cost is so low. Don't forget the lawsuites in Facebook > about the participants charged the founder in the courts. What do lawsuits have to do with replication costs? I suppose a person can fail a turing test... -- http://mail.python.org/mailman/listinfo/python-list
write binary with struct.pack_into
Dear pythonists,
I'm having a problem with read/write binary in python.
I have a binary file that I need to read information, extract a array,
modify this array and put these values into file again in same binary
format.
I need to use unpack_from and pack_into because sometimes gonna need
read/write in the middle of file.
Script:
import struct
bloco='>%df' %(252) #Binary format
# READ
fa=open('testIN.bin')
my_array=struct.unpack_from(bloco,fa.read()[0*4:251*4])# my_aray = 252
elements array
## This read is OK!
#WRITE
fb=open('testOUT.bin')
test=struct.pack_into(bloco,fb.write()[0*4:251*4]) # ERROR in this WRITE
Regards,
Ronaldo Palmeira.
--
View this message in context:
http://python.6.n6.nabble.com/write-binary-with-struct-pack-into-tp4991234.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list
Re: write binary with struct.pack_into
palmeira於 2012年10月6日星期六UTC+8上午11時27分47秒寫道:
> Dear pythonists,
>
>
>
> I'm having a problem with read/write binary in python.
>
> I have a binary file that I need to read information, extract a array,
>
> modify this array and put these values into file again in same binary
>
> format.
>
> I need to use unpack_from and pack_into because sometimes gonna need
>
> read/write in the middle of file.
>
>
>
> Script:
>
>
>
> import struct
>
> bloco='>%df' %(252) #Binary format
>
>
>
> # READ
>
> fa=open('testIN.bin')
>
> my_array=struct.unpack_from(bloco,fa.read()[0*4:251*4])# my_aray = 252
>
> elements array
>
> ## This read is OK!
>
>
>
> #WRITE
>
> fb=open('testOUT.bin')
>
> test=struct.pack_into(bloco,fb.write()[0*4:251*4]) # ERROR in this WRITE
>
>
>
>
>
>
>
>
>
> Regards,
>
>
>
> Ronaldo Palmeira.
>
>
>
>
>
>
>
>
>
> --
>
> View this message in context:
> http://python.6.n6.nabble.com/write-binary-with-struct-pack-into-tp4991234.html
>
> Sent from the Python - python-list mailing list archive at Nabble.com.
Are you writing and reading files produce by different
languages?
The pickle part is better for OOP and glue logics in python.
The heavy computing part should be done in CYTHON.
--
http://mail.python.org/mailman/listinfo/python-list
Re: notmm is dead!
On Saturday, 6 October 2012 08:29:02 UTC+5:30, Michael Torrie wrote: > On 10/05/2012 07:43 PM, 8 Dihedral wrote: > > > I think it is OK to have some string attatched in those open source > > projects. > > > > What are you talking about? What "string?" > > > > > Nowadays the software industry is just like the perfume and prtinting > > > and the audio-video entaertainment industry. > > > > True > > > > > The replication cost is so low. Don't forget the lawsuites in Facebook > > > about the participants charged the founder in the courts. > > > > What do lawsuits have to do with replication costs? > > > > I suppose a person can fail a turing test... You are talking to a bot. -- http://mail.python.org/mailman/listinfo/python-list
try/except KeyError vs "if name in ..."
Hi, I was looking at the example found here [1] which begins with: [1] http://docs.python.org/py3k/library/imp.html#examples def __import__(name, globals=None, locals=None, fromlist=None): # Fast path: see if the module has already been imported. try: return sys.modules[name] except KeyError: pass I was wondering if the formulation if name in sys.modules: return sys.modules[name] would be equivalent. IOW, is using try/except here only a matter of style or a necessity? I'm suspecting that maybe, in multithreaded environments, the second option may be subject to a race condition, if another thread removes name frome sys.modules between the if and the return, but as I'm not very familiar (yet) with Python threads, I'm not sure it is a real concern here. And maybe there are other reasons I'm completely missing for prefering EAFP over LBYL here? Thanks in advance for your comments. -- Manuel Pégourié-Gonnard - http://people.math.jussieu.fr/~mpg/ -- http://mail.python.org/mailman/listinfo/python-list
Re: write binary with struct.pack_into
On Sat, Oct 6, 2012 at 1:27 PM, palmeira wrote:
> import struct
> bloco='>%df' %(252) #Binary format
>
> # READ
> fa=open('testIN.bin')
> my_array=struct.unpack_from(bloco,fa.read()[0*4:251*4])# my_aray = 252
> elements array
> ## This read is OK!
>
> #WRITE
> fb=open('testOUT.bin')
> test=struct.pack_into(bloco,fb.write()[0*4:251*4]) # ERROR in this WRITE
You have a beautiful parallel here, but I think that's where your
problem is. In the READ section, you have fa.read() which will read
the whole file, and then you slice the resulting string. That's pretty
inefficient for large files, but it'll work.
But when you write, that completely does not work. (Even assuming
you've opened read/write, per Dennis's comment.)
>>> fb.write()
Traceback (most recent call last):
File "", line 1, in
fb.write()
TypeError: write() takes exactly 1 argument (0 given)
It needs an argument of what to write out, it doesn't return a
writable buffer suitable for pack_into.
I recommend you completely rewrite your file handling to use actual
seeks and file writes. Also, you'll want (I think) to use binary mode
on your files; character encodings don't mean much when you're working
with arrays of numbers.
Finally, when you post issues, "ERROR in this WRITE" isn't very
helpful. Please please post the full traceback (like in my trivial
example above), as problems will be much more visible.
Hope that's of some value!
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
