Re: Algorithm. Tony Gaddis book 2 Starting python3
Hello George, I found the book you're referring to via google (searching for: tony gaddis starting out with python). The question is this: 3. Write assignment statements that perform the following operations with the variables a,b and c. a. Adds 2 to a and assigns the result to b b. Multiplies b times 4 and assigns the result to a c. Divides a by 3.14 and assigns the result to b d. Subtracts 8 from and assigns the result to a The typical way this list helps in homework assignments is for the student to post his solution first, and then let someone explain if/why something is wrong, and how to go about the right solution. I think you will have a lot of fun learning python. It's very rewarding. Best regards, Stefaan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Algorithm. Tony Gaddis book 2 Starting python3
d. Subtracts 8 from and assigns the result to a this should read: "Subtracts 8 from b and assigns the result to a" Funny how none of the assignments involve a variable c, despite the question :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading Live Output from a Subprocess
Maybe this can help you? http://technogems.blogspot.com/2012/01/capture-colored-console-output-in.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Get the selected tab in a enthought traits application
Any ideas? I think you will have more chance for an answer in a more specialized list, e.g. the enthought-dev mailing list, which is also accessible via gmane: http:// dir.gmane.org / gmane.comp.python.enthought.devel Stefaan. -- https://mail.python.org/mailman/listinfo/python-list
Looking for download link for ArcPY
Hi, All, Can anyone send me the link for downloading ArcPY? I came across it before, but can not find it anymore. Regards. David-- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 108, Issue 98
Hi, Where do I find ArcPy.py? It seems that the link disappeared. Regards. David-- http://mail.python.org/mailman/listinfo/python-list
Looking for a simple, generic Python module to provide a secure web service
We are looking for a very simple, generic Python module to provide a secure web service. Ideally, it can be put onto the computer and make it available via IIS. Off we go. Your help will be gratefully received. Regards. David-- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 102, Issue 64
I am looking very simple and straightforward open source Python REST and SOAP demo modules. I really need things which are very simple and convincing. I want to demonstrate these to other people. I want to promote you guys' interest. I find asp and others frustrating and occupy too much in the market and popularity. Can we do a new tidal wave to win a reasonable portion of the development market? Send me materials to davidg...@yahoo.co.uk I will give it a go on behalf of the Python community. Regards. David From: "python-list-requ...@python.org" To: python-list@python.org Sent: Tuesday, 13 March 2012, 20:35 Subject: Python-list Digest, Vol 102, Issue 64 - Forwarded Message - Send Python-list mailing list submissions to python-list@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to python-list-requ...@python.org You can reach the person managing the list at python-list-ow...@python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." Today's Topics: 1. Re: concatenate function (James Elford) 2. Re: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! (Kiuhnm) 3. Re: Installing Python Apps on Mac Lion (dilvanezanard...@gmail.com) 4. Re: Software Engineer - (Pedro H. G. Souto) 5. Re: Software Engineer - (Neil Cerutti) 6. RE: Windows Contextmenu (Prasad, Ramit) 7. Re: concatenate function (ferreirafm) 8. Re: Installing Python Apps on Mac Lion (Benjamin Kaplan) 9. Re: Windows Contextmenu (Terry Reedy) 10. Re: concatenate function (Robert Kern) On 13/03/12 16:02, ferreirafm wrote: > Hi James, thank you for your replay. Indeed, the problem is qsub. And as > warned by Robert, I don't have functions properly, but just scripts. > > > -- > View this message in context: > http://python.6.n6.nabble.com/concatenate-function-tp4574176p4574511.html > Sent from the Python - python-list mailing list archive at Nabble.com. It looks like you're not calling wait() on your subprocesses: you're effectively launching a bunch of processes, then not waiting for them to finish before you ask the next process to operate on the same file. If you haven't given it a good look-over already, the subprocess documentation [1] is worth taking a little time over. [1]: http://docs.python.org/library/subprocess.html#popen-objects James On 3/12/2012 20:00, Albert van der Horst wrote: [...] Sorry for triple posting. I hadn't noticed the follow up and I was blaming my newsserver. BTW, Python is the next language (right after Perl) I'm going to learn. Then I'll probably have a look at Ruby... Kiuhnm Sábado, 25 de Junho de 2011 02h20min49s UTC+1, JKPeck escreveu: > The Lion version of the OS on the Mac comes with Python 2.7 installed, but it > is in /System/Library/Frameworks/..., and this area is not writable by third > party apps. > > So is there a consensus on what apps that typically install under the Python > site-packages directory should do in this situation? Installing Python from > python.org puts it in the writable area /Library/Frameworks/Python.framework. > > So, what should a Python app installer do? > > Thanks Hello, currently I have: /Library/Python/2.7/ /Library/Frameworks/Python.framework/Versions/2.7/ /Users/user/Library/Python/2.7/ With 3 folders "site-packages" and do not know why. What's the difference? Thanks. On 2012-03-13 12:44 PM, Paul Rudin wrote: > Just out of interest why do people object to job adverts here? Seems > harmless enough... Wannabe list admins... Or list admins with a need to proof themselves... Or none of the above. On 2012-03-13, Pedro H. G. Souto wrote: > On 2012-03-13 12:44 PM, Paul Rudin wrote: >> Just out of interest why do people object to job adverts here? >> Seems harmless enough... > > Wannabe list admins... Or list admins with a need to proof > themselves... Or none of the above. A job listing here or there would fine. If the discussion were clogged with them, it would be really annoying. In addition, it's more efficient to post job listing in a place where people looking for jobs can easily find them, and it's annoying and useless to post them in a place where reader not looking for jobs have to delete them. -- Neil Cerutti > > Now the script runs fine but I don't get all arguments from sys.argv. > > > > No mather how many files I mark in the explorer I only get one as an > > argument. > > You're missing out vital information: > > * How have you attached this code to the context menu? What was > the exact registry entry (or other method) you used? From a quick Google search, it seems that most of the context menu entries open a single file. If multiple file
Looking for proven Python code for Line Simplication such as Douglas-Peucker
Dear All, I am looking for proven Python code for Line Simplication such as Douglas-Peucker. Regards. David -- http://mail.python.org/mailman/listinfo/python-list
How to call and execute C code in Python?
Can anyone tell me how to call and exectute C code in Python? Regards. David From: "python-list-requ...@python.org" To: python-list@python.org Sent: Friday, 11 May 2012, 5:35 Subject: Python-list Digest, Vol 104, Issue 57 - Forwarded Message - Send Python-list mailing list submissions to python-list@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to python-list-requ...@python.org You can reach the person managing the list at python-list-ow...@python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." Today's Topics: 1. Looking for video/slides from PyCon 2011... (Monte Milanuk) 2. Re: Dealing with the __str__ method in classes with lots of attributes (Cameron Simpson) 3. RE: Open Source: you're doing it wrong - the Pyjamas hijack (Adrian Hunt) 4. RE: Creating a Windows installer for Python + a set of dependencies (Adrian Hunt) 5. Re: Open Source: you're doing it wrong - the Pyjamas hijack (Chris Angelico) 6. Re: Retrieving result from embedded execution (Chris Angelico) 7. Finding the line number of an 'else' statement via ast (Michael Rene Armida) ...specifically the two lectures on creating GUI applications with Python + QT http://us.pycon.org/2011/schedule/presentations/207/ Various searches on the 'Net don't seem to be turning up much... kinda curious as to why? Anyone here know? TIA, Monte On 10May2012 15:33, Andreas Tawn wrote: | Say I've got a class... | | class test(object): | def __init__(self): | self.foo = 1 | self.bar = 2 | self.baz = 3 | | I can say... | | def __str__(self): | return "foo: {0}\nbar: {1}\nbaz: {2}".format(self.foo, self.bar, self.baz) | | and everything's simple and clean and I can vary the formatting if I need to. | | This gets ugly when the class has a lot of attributes because the string construction gets very long. This issue bit me once too often a few months ago, and now I have a class called "O" from which I often subclass instead of from "object". Its main purpose is a friendly __str__ method, though it also has a friendly __init__. Code: class O(object): ''' A bare object subclass to allow storing arbitrary attributes. It also has a nicer default str() action, and an aggressive repr(). ''' def __init__(self, **kw): ''' Initialise this O. Fill in attributes from any keyword arguments if supplied. This call can be omitted in subclasses if desired. ''' for k in kw: setattr(self, k, kw[k]) def __str__(self): return ( "<%s %s>" % ( self.__class__.__name__, ",".join([ "%s=%s" % (attr, getattr(self, attr)) for attr in sorted(dir(self)) if attr[0].isalpha() ]) ) ) So I have some code thus: from cs.misc import O .. class FilterModes(O): def __init__(self, **kw): # special case one parameter self._maildb_path = kw.pop('maildb_path') self._maildb_lock = allocate_lock() O.__init__(self, **kw) .. filter_modes = FilterModes(justone=justone, delay=delay, no_remove=no_remove, no_save=no_save, maildb_path=os.environ['MAILDB'], maildir_cache={}) This removes a lot of guff from some common procedures. Hope this helps, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ There's a fine line between pathos and pathetic. - David Stivers s...@stat.rice.edu DoD #857 lol, Cheers Chris. Just so you know, I care about what and how I write... I almost always run my emails though a word-processor before sending. And, that has paid off for me: thanks to MS Word, MS Works and Open Office, I have better understanding of "correct" punctuation use (if not spelling and grammar) than most school leavers!!! PS. It hasn't gone a miss that you are one of the core python-list responders (and I bet this goes for most of the python-list users): your responses, time and knowledge is appreciated... Thank you. > Date: Fri, 11 May 2012 09:57:49 +1000 > Subject: Re: Open Source: you're doing it wrong - the Pyjamas hijack > From: ros...@gmail.com > To: python-list@python.org > > On Fri, May 11, 2012 at 9:36 AM, Adrian Hunt wrote: > > All I did was to answer a mail sent to me by Ian Kelly (who I don't konw nor > > have ever had any prior contact with) about releasing code under a > > license... And, what I said stands: once anyone releases code, they are > > bound by the license the
How to call and execute C code in Python?
How to call and execute C code in Python? Is there any publication/documentation for this? For the worst scenario, how many ways are there to call and execute C codes, in Python. For instance, having got hold some C codes, attempting to use Python to call and execute C codes. I.e. Python, as the integrating language. Can anyone send publications/instructions to davidg...@yahoo.co.uk? All the best to everyone! Regards. David From: "python-list-requ...@python.org" To: python-list@python.org Sent: Sunday, 13 May 2012, 19:14 Subject: Python-list Digest, Vol 104, Issue 67 - Forwarded Message - Send Python-list mailing list submissions to python-list@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to python-list-requ...@python.org You can reach the person managing the list at python-list-ow...@python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." Today's Topics: 1. Re: Good data structure for finding date intervals including a given date (Arnaud Delobelle) 2. Re: Good data structure for finding date intervals including a given date (Emile van Sebille) 3. Re: How to call and execute C code in Python? (Chris Angelico) 4. Re: How to call and execute C code in Python? (Stefan Behnel) 5. Re: How to call and execute C code in Python? (Mark Lawrence) 6. Re: How to call and execute C code in Python? (Mark Lawrence) 7. Re: How to call and execute C code in Python? (Stefan Behnel) 8. Re: How to call and execute C code in Python? (Stefan Behnel) 9. Re: How to call and execute C code in Python? (Mark Lawrence) 10. Re: How to call and execute C code in Python? (Stefan Behnel) On 13 May 2012 13:29, Alec Taylor wrote: > There is an ordered dict type since Python 3.1[1] and Python 2.7.3[2]. I don't think that'll help the OP. Python's OrderedDict keeps track of the order in which the keys were inserted into the dictionary (a bit like a list), it doesn't keep the keys sorted. > If you are looking for the best possible self-sorting structure for > searching, then perhaps you are looking for what's outlined in the > 2002 article by Han & Thorup: Integer Sorting in O(n sqrt(log log n)) > Expected Time and Linear Space[3]. I can't access it but it seems to me it's not about self sorted data structures, which is what the OP is looking for. -- Arnaud On 5/12/2012 5:17 AM Jean-Daniel said... > Hello, > > I have a long list of n date intervals that gets added or suppressed > intervals regularly. I am looking for a fast way to find the intervals > containing a given date, without having to check all intervals (less > than O(n)). ISTM the fastest way is to retrieve the list of intervals from a dict using the date as a key. You don't say how long your list of intervals is, nor how large each interval can be so I don't have enough info to determine the setup reqs, but I'd suspect that a list of tens of thousands of intervals covering ranges of days to weeks would be doable. If instead you're talking about millions of ranges covering years to decades I'd start elsewhere. Emile On Sun, May 13, 2012 at 11:25 PM, David Shi wrote: > Can anyone tell me how to call and exectute C code in Python? Browse the documentation about Extending and Embedding Python, there's an extensive API. Chris Angelico David Shi, 13.05.2012 15:25: > Can anyone tell me how to call and exectute C code in Python? Take a look at Cython, a Python-like language that supports native calls to and from C/C++ code. It translates your code into very efficient C code, so the wrapping code tends to be very fast (often faster than hand written C code). http://cython.org/ Here are a couple of examples: http://docs.cython.org/src/tutorial/external.html There's also the "ctypes" package in the standard library, which is usable for simple wrapping cases that are not performance critical. Stefan On 13/05/2012 16:39, Chris Angelico wrote: > On Sun, May 13, 2012 at 11:25 PM, David Shi wrote: >> Can anyone tell me how to call and exectute C code in Python? > > Browse the documentation about Extending and Embedding Python, there's > an extensive API. > > Chris Angelico I like your response, my first thought was to say "yes" :) -- Cheers. Mark Lawrence. On 13/05/2012 16:58, Stefan Behnel wrote: > David Shi, 13.05.2012 15:25: >> Can anyone tell me how to call and exectute C code in Python? > > Take a look at Cython, a Python-like language that supports native calls to > and from C/C++ code. It translates your cod
Looking for Python script for Vector Map simplification, preserving shape and topology
Dear All, I am looking for Python script for Vector Map simplification, preserving shape and topology. Please get in touch with davidg...@yahoo.co.uk Regards. David -- http://mail.python.org/mailman/listinfo/python-list
While stack:
Can any one clarify what "while stack:" mean? Regards, David -- http://mail.python.org/mailman/listinfo/python-list
Where is the latest step by step guide to use Jython to compile Python into Java?
Hello, Where is the latest step by step guide to use Jython to compile Python into Java? I found that it was very confusing by reading not updated text. Please help. Regards. David -- http://mail.python.org/mailman/listinfo/python-list
Re: Where is the latest step by step guide to use Jython to compilePython into Java?
Mohan, Please see the following link as an example. http://www.ssec.wisc.edu/~tomw/visadtutor/compile.html I just can not make any success with some of these instructions. Compiling your Python code with jythonc I do not know whether I downloaded a wrong version of Jythonc? Or, got mismatched software or instructions. Please provide assistance, by providing the tested software and instructions. Regards. David From: "Narayanaswamy, Mohan" To: David Shi Cc: python-list@python.org Sent: Monday, 4 June 2012, 15:56 Subject: RE: Where is the latest step by step guide to use Jython to compilePython into Java? David, As per my knowledge, You can’t find steps to convert python into java anywhere. 1) I am not expert in python, but familiar with Java. Python by default uses python-vm and converts into byte code, which is not compatible with JVM byte-code, Jython/Jruby/Jxxx are supporting languages on top of JVM. Jython is executing python on top of JVM, by doing that, we can make use of java library inside python and/or vice versa. 2) Python is dynanmic programming (but strongly typed), java is static-typed language. Currently it is not possible to convert python into java, since python types are dynamically identified, not identified during compilation. Regards Mohan From:python-list-bounces+mohan.narayanaswamy-2=sc@python.org [mailto:python-list-bounces+mohan.narayanaswamy-2=sc@python.org] On Behalf Of David Shi Sent: Monday, June 04, 2012 10:36 PM To: python-list@python.org Subject: Where is the latest step by step guide to use Jython to compilePython into Java? Hello, Where is the latest step by step guide to use Jython to compile Python into Java? I found that it was very confusing by reading not updated text. Please help. Regards. David This email and any attachments are confidential and may also be privileged. If you are not the addressee, do not disclose, copy, circulate or in any other way use or rely on the information contained in this email or any attachments. If received in error, notify the sender immediately and delete this email and any attachments from your system. Emails cannot be guaranteed to be secure or error free as the message and any attachments could be intercepted, corrupted, lost, delayed, incomplete or amended. Standard Chartered PLC and its subsidiaries do not accept liability for damage caused by this email or any attachments and may monitor email traffic. Standard Chartered PLC is incorporated in England with limited liability under company number 966425 and has its registered office at 1 Aldermanbury Square, London, EC2V 7SB. Standard Chartered Bank ("SCB") is incorporated in England with limited liability by Royal Charter 1853, under reference ZC18. The Principal Office of SCB is situated in England at 1 Aldermanbury Square, London EC2V 7SB. In the United Kingdom, SCB is authorised and regulated by the Financial Services Authority under FSA register number 114276. If you are receiving this email from SCB outside the UK, please click http://www.standardchartered.com/global/email_disclaimer.html to refer to the information on other jurisdictions.-- http://mail.python.org/mailman/listinfo/python-list
Re: Where is the latest step by step guide to use Jython to compilePython into Java?
Hello, Mohan, Did you test it? I am using Windows. Where are the exact steps for compiling in DOS? Once .class or jar files created, how to use these files? Could you enlighten me with tested/proven step by step instructions? Regards. David From: "Narayanaswamy, Mohan" To: David Shi Cc: python-list@python.org Sent: Monday, 4 June 2012, 16:38 Subject: RE: Where is the latest step by step guide to use Jython to compilePython into Java? David, Thanks for the link, here that compilation steps won’t produce java code, but it could create .class file (or jar). Regards Mohan From:David Shi [mailto:davidg...@yahoo.co.uk] Sent: Monday, June 04, 2012 11:35 PM To: Narayanaswamy, Mohan Cc: python-list@python.org Subject: Re: Where is the latest step by step guide to use Jython to compilePython into Java? Mohan, Please see the following link as an example. http://www.ssec.wisc.edu/~tomw/visadtutor/compile.html I just can not make any success with some of these instructions. Compiling your Python code with jythonc I do not know whether I downloaded a wrong version of Jythonc? Or, got mismatched software or instructions. Please provide assistance, by providing the tested software and instructions. Regards. David From:"Narayanaswamy, Mohan" To: David Shi Cc: python-list@python.org Sent: Monday, 4 June 2012, 15:56 Subject: RE: Where is the latest step by step guide to use Jython to compilePython into Java? David, As per my knowledge, You can’t find steps to convert python into java anywhere. 1) I am not expert in python, but familiar with Java. Python by default uses python-vm and converts into byte code, which is not compatible with JVM byte-code, Jython/Jruby/Jxxx are supporting languages on top of JVM. Jython is executing python on top of JVM, by doing that, we can make use of java library inside python and/or vice versa. 2) Python is dynanmic programming (but strongly typed), java is static-typed language. Currently it is not possible to convert python into java, since python types are dynamically identified, not identified during compilation. Regards Mohan From:python-list-bounces+mohan.narayanaswamy-2=sc@python.org [mailto:python-list-bounces+mohan.narayanaswamy-2=sc@python.org] On Behalf Of David Shi Sent: Monday, June 04, 2012 10:36 PM To: python-list@python.org Subject: Where is the latest step by step guide to use Jython to compilePython into Java? Hello, Where is the latest step by step guide to use Jython to compile Python into Java? I found that it was very confusing by reading not updated text. Please help. Regards. David This email and any attachments are confidential and may also be privileged. If you are not the addressee, do not disclose, copy, circulate or in any other way use or rely on the information contained in this email or any attachments. If received in error, notify the sender immediately and delete this email and any attachments from your system. Emails cannot be guaranteed to be secure or error free as the message and any attachments could be intercepted, corrupted, lost, delayed, incomplete or amended. Standard Chartered PLC and its subsidiaries do not accept liability for damage caused by this email or any attachments and may monitor email traffic. Standard Chartered PLC is incorporated in England with limited liability under company number 966425 and has its registered office at 1 Aldermanbury Square, London, EC2V 7SB. Standard Chartered Bank ("SCB") is incorporated in England with limited liability by Royal Charter 1853, under reference ZC18. The Principal Office of SCB is situated in England at 1 Aldermanbury Square, London EC2V 7SB. In the United Kingdom, SCB is authorised and regulated by the Financial Services Authority under FSA register number 114276. If you are receiving this email from SCB outside the UK, please click http://www.standardchartered.com/global/email_disclaimer.html to refer to the information on other jurisdictions. This email and any attachments are confidential and may also be privileged. If you are not the addressee, do not disclose, copy, circulate or in any other way use or rely on the information contained in this email or any attachments. If received in error, notify the sender immediately and delete this email and any attachments from your system. Emails cannot be guaranteed to be secure or error free as the message and any attachments could be intercepted, corrupted, lost, delayed, incomplete or amended. Standard Chartered PLC and its subsidiaries do not accept liability for damage caused by this email or any attachments and may monitor email traffic. Standard Chartered PLC is incorporated in England with limited liability under company number 966425 and has its registered office at 1 Aldermanbury Square, London, EC2V
Has theHas Python community got Alan Saalfeld et al's algorithm and source code implementation
Dear Python community friends, I wonder whether there is such a Python implementation available. Alan Saalfeld et al's algorithm and source codes. http://books.google.ie/books/about/A_Modified_Douglas_Peucker_Simplificatio.html?id=gbQjywAACAAJ&redir_esc=y In Zhiyuan Zhao and Alan Saafeld's paper, LINEAR-TIME SLEEVE-FITTING POLYLINE SIMPLIFICATION ALGORITHMS Zhiyuan Zhao, Alan Saalfeld They mentioned " The results of those experiments and more information on the algorithms themselves, including complete working code, are available to the interested reader at the World Wide Web site http://ra.cfm.ohio-state.edu/grad/zhao/algorithms/linesimp.html."; However, this site is no longer alive. If anyone knows, please let me know. davidg...@yahoo.co.uk Regards. David-- http://mail.python.org/mailman/listinfo/python-list
Where is the lastest step by step guide to compile Python into an executable?
Hi, folks. Where is the lastest step by step guide to compile Python into an executable? Regards. David -- http://mail.python.org/mailman/listinfo/python-list
Re: tree representation of Python data
What is the robust way to use Python to read in an XML and turn it into a JSON file? JSON dictionary is actually a tree. It is much easier to manage the tree-structured data. Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Automated data testing, checking, validation, reporting for data assurance
There appear to be a few options for this. Has anyone tested and got experience with automated data testing, validation and reporting? Can anyone enlighten me? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Definitive guide for Regex
Dear All, I am trying to look for a definitive guide for Regex in Python. Can anyone help? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Re: Definitive guide for Regex
Hi, Barry, In cases of automating checking, validation and producing reports in the context of data quality control and giving specific feedback to production teams, regex is perhaps the only way. Perhaps, we can give each element of data specifications a name, that are associated with a regex value, so that we can automate checking and reporting on data sets. We can report on which row of records meet specification and requirements and which one is not. And, report on which cell needs to be corrected should a row is found not meeting specification and requirements. What do you think? Regards, David On Thu, 30 Sept 2021 at 22:02, Barry Scott wrote: > > > > On 30 Sep 2021, at 19:35, dn via Python-list > wrote: > > > > On 01/10/2021 06.16, Barry Scott wrote: > >> > >> > >>> On 30 Sep 2021, at 12:29, Shaozhong SHI > wrote: > >>> > >>> Dear All, > >>> > >>> I am trying to look for a definitive guide for Regex in Python. > >>> Can anyone help? > >> > >> Have you read the python docs for the re module? > > > > > > I learned from Jeffrey Friedl's book "Mastering Regular Expressions", > > but that was in a land far away, last century, and under a different > > language (and the original version - I see it's now up to its third > > edition). > > > > Despite their concise exercise of power (and the fact that in my > > Python-life I've never been put into a corner where I absolutely must > > use one), I'm no longer a fan... > > Agreed, regex is the last tool I reach for in python code. > I find I use split() a lot to break up strings for processing. > But there are cases where a regex is the best tool for a particular job > and I then use the re module. But it costs in maintainability. > > I speak as the author of a regex engine and know how to write scary > regex's when the need arises. > > Barry > > > > -- > > Regards, > > =dn > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Connecting to MS accdb and read data into Pandas
I tried the following code: import pyodbc conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D:\my.accdb;') cursor = conn.cursor() cursor.execute('select * from table_name') for row in cursor.fetchall(): print (row) But I could not connect to .accdb. What is the robust way to set the connection string? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
SQLAlchemy fault
I read a txt file into Pandas Dataframe, and found a lot of nulls in a column. Then, I used SQLAlchemy and psycopg2. I created engine. I loaded data onto PostgreSQL. Strange thing happened. The column has no null at all. Does it mean that the data has been modified somewhere along the line? Does anyone know the robust and fast loading of Pandas frame data onto Postgres database? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Alternatives to Jupyter Notebook
Hello, Is anyone familiar with alternatives to Jupyter Notebook. My Jupyter notebook becomes unresponsive in browsers. Are there alternatives to read, edit and run Jupyter Notebook? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
df.count() to a Pandas dataframe with column names
How to output the result of df.count() to a Pandas dataframe with column names? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
How to store the result of df.count() as a new dataframe in Pandas?
Hello, The result of df.count() appears to be a series object. How to store the result of df.count() as a new dataframe in Pandas? That is data anyhow. Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Python script seems to stop running when handling very large dataset
Python script works well, but seems to stop running at a certain point when handling very large dataset. Can anyone shed light on this? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Re: Python script seems to stop running when handling very large dataset
On Saturday, 30 October 2021, Dieter Maurer wrote: > Shaozhong SHI wrote at 2021-10-29 23:42 +0100: > >Python script works well, but seems to stop running at a certain point > when > >handling very large dataset. > > > >Can anyone shed light on this? > > Some algorithms have non linear runtime. > > > For example, it is quite easy to write code with > quadratic runtime in Python: > s = "" > for x in ...: s += f(x) > You will see the problem only for large data sets. > Has anyone compared this with iterrow? which looping option is faster? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
How to apply a self defined function in Pandas
I defined a function and apply it to a column in Pandas. But it does not return correct values. I am trying to test which url in a column full of url to see which one can be connected to or not def connect(url): try: urllib.request.urlopen(url) return True except: return False df['URL'] = df.apply(lambda x: connect(df['URL']), axis=1) I ran without any error, but did not return any true. I just could not find any error with it. Can anyone try and find out why Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Re: How to apply a self defined function in Pandas
On Sunday, 31 October 2021, Albert-Jan Roskam wrote: > > > > df['URL'] = df.apply(lambda x: connect(df['URL']), axis=1) > > > I think you need axis=0. Or use the Series, df['URL'] = > df.URL.apply(connect) > Any details? I will try and let you know. Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Re: How to apply a self defined function in Pandas
On Sunday, 31 October 2021, MRAB wrote: > On 2021-10-31 17:25, Shaozhong SHI wrote: > >> I defined a function and apply it to a column in Pandas. But it does not >> return correct values. >> >> I am trying to test which url in a column full of url to see which one can >> be connected to or not >> >> def connect(url): >> try: >> urllib.request.urlopen(url) >> return True >> except: >> return False >> >> df['URL'] = df.apply(lambda x: connect(df['URL']), axis=1) >> >> I ran without any error, but did not return any true. >> >> I just could not find any error with it. >> >> Can anyone try and find out why >> >> You're passing a function to '.apply'. That has one argument,' x'. > > But what is the function doing with that argument? > > Nothing. > > The function is just returning the result of connect(df['URL']). > > df['URL'] is a column, so you're passing a column to '.urlopen', which, of > course, it doesn't understand. > > So 'connect' returns False. > > Please expand on how. David > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: How to apply a self defined function in Pandas
On Sun, 31 Oct 2021 at 19:28, MRAB wrote: > On 2021-10-31 18:48, Shaozhong SHI wrote: > > > > On Sunday, 31 October 2021, MRAB wrote: > > > > On 2021-10-31 17:25, Shaozhong SHI wrote: > > > > I defined a function and apply it to a column in Pandas. But > > it does not > > return correct values. > > > > I am trying to test which url in a column full of url to see > > which one can > > be connected to or not > > > > def connect(url): > > try: > > urllib.request.urlopen(url) > > return True > > except: > > return False > > > > df['URL'] = df.apply(lambda x: connect(df['URL']), axis=1) > > > > I ran without any error, but did not return any true. > > > > I just could not find any error with it. > > > > Can anyone try and find out why > > > > You're passing a function to '.apply'. That has one argument,' x'. > > > > But what is the function doing with that argument? > > > > Nothing. > > > > The function is just returning the result of connect(df['URL']). > > > > df['URL'] is a column, so you're passing a column to '.urlopen', > > which, of course, it doesn't understand. > > > > So 'connect' returns False. > > > > > > Please expand on how. > > > It's as simple as passing 'connect' to '.apply' as the first argument. > Well, can you expand the the simplicity? Regards, David > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: How to apply a self defined function in Pandas
On Sun, 31 Oct 2021 at 18:42, Shaozhong SHI wrote: > > > On Sunday, 31 October 2021, Albert-Jan Roskam > wrote: > >> >> >> > df['URL'] = df.apply(lambda x: connect(df['URL']), axis=1) >> >> >> I think you need axis=0. Or use the Series, df['URL'] = >> df.URL.apply(connect) >> > > Just experimented with your suggestion, but have not seen any difference. > Regards, David -- https://mail.python.org/mailman/listinfo/python-list
System, configuration and Python performance
How to configure to improve Python performance in a system like the following: Windows 10 System Processor Intel(R) Core(TM) i7-9700 CPU @3.60GHz, 3.60 GHz Installed memory (RAM) 32.0 GB (31.8 GB usable) System type: 64-bit Operating System, x64-based processor I found that the Python script was runnig slowly and wanted to find out what is going on and what activities it is doing. I opened the Task Manager and found that there is not much CPU usage. Do I need to do something like configuration to improve Python's performance? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Re: System, configuration and Python performance
On Tue, 2 Nov 2021 at 00:09, MRAB wrote: > On 2021-11-01 23:02, Shaozhong SHI wrote: > > How to configure to improve Python performance in a system like the > > following: > > > > Windows 10 > > > > System > > > > Processor Intel(R) Core(TM) i7-9700 CPU @3.60GHz, 3.60 GHz > > Installed memory (RAM) 32.0 GB (31.8 GB usable) > > System type: 64-bit Operating System, x64-based processor > > > > I found that the Python script was runnig slowly and wanted to find out > > what is going on and what activities it is doing. > > > > I opened the Task Manager and found that there is not much CPU usage. > > > > Do I need to do something like configuration to improve Python's > > performance? > > > If CPU usage is low, then that isn't the cause of the slowness. > > What about disk usage? > > What about network usage? > > If it's communicating across the internet, then it might be waiting for > the other end. If that's the case, then there's probably not much you > can do about it. > Both disk usage and network usage are very low as well. It is checking out responses of internet pages with given URLs. Regards, David > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: System, configuration and Python performance
On Tue, 2 Nov 2021 at 00:20, Shaozhong SHI wrote: > > > On Tue, 2 Nov 2021 at 00:09, MRAB wrote: > >> On 2021-11-01 23:02, Shaozhong SHI wrote: >> > How to configure to improve Python performance in a system like the >> > following: >> > >> > Windows 10 >> > >> > System >> > >> > Processor Intel(R) Core(TM) i7-9700 CPU @3.60GHz, 3.60 GHz >> > Installed memory (RAM) 32.0 GB (31.8 GB usable) >> > System type: 64-bit Operating System, x64-based processor >> > >> > I found that the Python script was runnig slowly and wanted to find out >> > what is going on and what activities it is doing. >> > >> > I opened the Task Manager and found that there is not much CPU usage. >> > >> > Do I need to do something like configuration to improve Python's >> > performance? >> > >> If CPU usage is low, then that isn't the cause of the slowness. >> >> What about disk usage? >> >> What about network usage? >> >> If it's communicating across the internet, then it might be waiting for >> the other end. If that's the case, then there's probably not much you >> can do about it. >> > > Both disk usage and network usage are very low as well. > > It is checking out responses of internet pages with given URLs. > > It is checking out whether each url is valid or not. > > > >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > -- https://mail.python.org/mailman/listinfo/python-list
Installation of GeoPandas - failed at fiona
I am trying to install geopandas. I navigated to c:\programData|Anaconda3\Scripts> and typed in 'pip install geopandas'. It ran but failed at fiona. I tried import geopandas as gp, but Error Message says: No module names 'geopandas'. Can anyone help? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
ogr2ogr can not open gfs file when loading GML
My command line kept telling me that it ogr2ogr can not open gfs file. It does find it. I was trying to load GML onto PostGIS. Alternatively, how to specify XSD file to go along with reading GML files? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Can Python call and use FME modules and functions such as StreamOrderCalculator?
Can we do something like import an fme.something and make use of FME modules and functions? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
How to set environmental variables for Python
I got quite a few version of Python on my machine. How do I set environmental variables for Python 3.6.1 to work? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Re: How to set environmental variables for Python
Set Operation System but not disturbing existing setting. Only to add at the command line. Regards, David On Mon, 17 Jan 2022 at 10:57, dn via Python-list wrote: > On 17/01/2022 22.31, Shaozhong SHI wrote: > > I got quite a few version of Python on my machine. > > > > How do I set environmental variables for Python 3.6.1 to work? > > > Set from Python, or set in the OpSys? > > https://docs.python.org/3/library/os.html?highlight=environment%20variable > > MS-Win: https://docs.python.org/3/using/windows.html#setting-envvars > -- > Regards, > =dn > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
URLError:
The following is used in a loop to get response code for each url. print (urllib.request.urlopen(url).getcode()) However, error message says: URLError: Python 3.6.5 is being used to test whether url is live or not. Can anyone shed light on this? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Long running process - how to speed up?
I have a cvs file of 932956 row and have to have time.sleep in a Python script. It takes a long time to process. How can I speed up the processing? Can I do multi-processing? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Re: Long running process - how to speed up?
Can it be divided into several processes? Regards, David On Saturday, 19 February 2022, Chris Angelico wrote: > On Sat, 19 Feb 2022 at 22:59, Karsten Hilbert > wrote: > > > > > > I have a cvs file of 932956 row and have to have time.sleep in a > Python > > > > script. It takes a long time to process. > > > > > > > > How can I speed up the processing? Can I do multi-processing? > > > > > > > Remove the time.sleep()? > > > > He's attesting to only having "time.sleep" in there... > > > > I doubt removing that will help much ;-) > > I honestly don't understand the question, hence offering the > stupidly-obvious suggestion in the hope that it would result in a > better question. A million rows of CSV, on its own, isn't all that > much to process, so it must be the processing itself (of which we have > no information other than this reference to time.sleep) that takes all > the time. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Long running process - how to speed up?
On Sat, 19 Feb 2022 at 19:44, Mats Wichmann wrote: > On 2/19/22 05:09, Shaozhong SHI wrote: > > Can it be divided into several processes? > > Regards, > > David > > The answer is: "maybe". Multiprocessing doesn't happen for free, you > have to figure out how to divide the task up, requiring thought and > effort. We can't guess to what extent the problem you have is amenable > to multiprocessing. > > Google for "dataframe" and "multiprocessing" and you should get some > hits (in my somewhat limited experience in this area, people usually > load the csv data into Pandas before they get started working with it). > > > -- > https://mail.python.org/mailman/listinfo/python-list I am trying this approach, import multiprocessing as mp def my_func(x): print(x**x) def main(): pool = mp.Pool(mp.cpu_count()) result = pool.map(my_func, [4,2,3]) if __name__ == "__main__": main() I modified the script and set off a test run. However, I have no idea whether this approach will be faster than conventional approach. Any one has idea? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Re: Re: Long running process - how to speed up?
On Sat, 19 Feb 2022 at 18:51, Alan Gauld wrote: > On 19/02/2022 11:28, Shaozhong SHI wrote: > > > I have a cvs file of 932956 row > > That's not a lot in modern computing terms. > > > and have to have time.sleep in a Python > > script. > > Why? Is it a requirement by your customer? Your manager? > time.sleep() is not usually helpful if you want to do > things quickly. > > > It takes a long time to process. > > What is a "long time"? minutes? hours? days? weeks? > > It should take a million times as long as it takes to > process one row. But you have given no clue what you > are doing in each row. > - reading a database? > - reading from the network? or the internet? > - writing to a database? or the internet? > - performing highly complex math operations? > > Or perhaps the processing load is in analyzing the totality > of the data after reading it all? A very different type > of problem. But we just don't know. > > All of these factors will affect performance. > > > How can I speed up the processing? > > It all depends on the processing. > You could try profiling your code to see where the time is spent. > > > Can I do multi-processing? > > Of course. But there is no guarantee that will speed things > up if there is a bottleneck on a single resource somewhere. > But it might be possible to divide and conquer and get better > speed. It all depends on what you are doing. We can't tell. > > We cannot answer such a vague question with any specific > solution. > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > -- > https://mail.python.org/mailman/listinfo/python-list Do not know these answers yet. Now, it appeared to hang/stop at a point and does not move on. Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Issues of pip install gdal and fiona
I downloaded .whl files for fiona and gdal to go with Python3.6.5. However, I am having trouble with red error messages. Though Gdal is now working, there is a warning message - Missing global ~ gdal: DRIVER_NAME declaration gdal_array,py Can anyone advise on how to resolve the issues? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Missing global # gdal DRIVER_NAME declaration in gdal_array.py
The following warning kept coming up when running ogr2ogr. Warning 1: Missing global # gdal: DRIVER_NAME declaration in C:\Users\AppData\Local\Programs\Python\Python36\Lib\site-packages\osgeo\gdal_array.py What steps to be take to resolve this issue? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
ValueError: arrays must all be same length
Hello, I got a json response from an API and tried to use pandas to put data into a dataframe. However, I kept getting this ValueError: arrays must all be same length. Can anyone help? The following is the json text. Regards, Shao { "locationId": "1-1004508435", "providerId": "1-101641521", "organisationType": "Location", "type": "Social Care Org", "name": "Meadow Rose Nursing Home", "brandId": "BD510", "brandName": "BRAND MACC Care", "onspdCcgCode": "E38000220", "onspdCcgName": "NHS Birmingham and Solihull CCG", "odsCode": "VM4G9", "uprn": "100070537642", "registrationStatus": "Registered", "registrationDate": "2013-12-16", "dormancy": "N", "numberOfBeds": 56, "postalAddressLine1": "96 The Roundabout", "postalAddressTownCity": "Birmingham", "postalAddressCounty": "West Midlands", "region": "West Midlands", "postalCode": "B31 2TX", "onspdLatitude": 52.399843, "onspdLongitude": -1.989241, "careHome": "Y", "inspectionDirectorate": "Adult social care", "mainPhoneNumber": "01214769808", "constituency": "Birmingham, Northfield", "localAuthority": "Birmingham", "lastInspection": { "date": "2020-06-24" }, "lastReport": { "publicationDate": "2020-10-01" }, "relationships": [ ], "locationTypes": [ ], "regulatedActivities": [ { "name": "Accommodation for persons who require nursing or personal care", "code": "RA2", "contacts": [ { "personTitle": "Mr", "personGivenName": "Steven", "personFamilyName": "Kazembe", "personRoles": [ "Registered Manager" ] } ] }, { "name": "Treatment of disease, disorder or injury", "code": "RA5", "contacts": [ { "personTitle": "Mr", "personGivenName": "Steven", "personFamilyName": "Kazembe", "personRoles": [ "Registered Manager" ] } ] } ], "gacServiceTypes": [ { "name": "Nursing homes", "description": "Care home service with nursing" } ], "inspectionCategories": [ { "code": "S1", "primary": "true", "name": "Residential social care" } ], "specialisms": [ { "name": "Caring for adults over 65 yrs" }, { "name": "Caring for adults under 65 yrs" }, { "name": "Dementia" }, { "name": "Physical disabilities" } ], "inspectionAreas": [ ], "currentRatings": { "overall": { "rating": "Requires improvement", "reportDate": "2020-10-01", "reportLinkId": "1157c975-c2f1-423e-a2b4-66901779e014", "useOfResources": { }, "keyQuestionRatings": [ { "name": "Safe", "rating": "Requires improvement", "reportDate": "2020-10-01", "reportLinkId": "1157c975-c2f1-423e-a2b4-66901779e014" }, { "name": "Well-led", "rating": "Requires improvement", "reportDate": "2020-10-01", "reportLinkId": "1157c975-c2f1-423e-a2b4-66901779e014" }, { "name": "Caring", "rating": "Good", "reportDate": "2019-10-04", "reportLinkId": "63ff05ec-4d31-406e-83de-49a271cfdc43" }, { "name": "Responsive", "rating": "Good", "reportDate": "2019-10-04", "reportLinkId": "63ff05ec-4d31-406e-83de-49a271cfdc43" }, { "name": "Effective", "rating": "Requires improvement", "reportDate": "2019-10-04", "reportLinkId": "63ff05ec-4d31-406e-83de-49a271cfdc43" } ] }, "reportDate": "2020-10-01" }, "historicRatings": [ { "reportLinkId": "63ff05ec-4d31-406e-83de-49a271cfdc43", "reportDate": "2019-10-04", "overall": { "rating": "Requires improvement", "keyQuestionRatings": [ { "name": "Safe", "rating": "Requires improvement" }, { "name": "Well-led", "rating": "Requires improvement" } ] } }, { "reportLinkId": "4f20da40-89a4-4c45-a7f9-bfd52b48f286", "reportDate": "2017-09-08", "overall": { "rating": "Good", "keyQuestionRatings": [ { "name": "Safe", "rating": "Good" }, { "name": "Well-led", "rating": "Good" }, { "name": "Caring", "rating": "Good" }, { "name": "Responsive", "rating": "Good" }, { "name": "Effective", "rating": "Requires improvement" } ] } }, { "reportLinkId": "0cc4226b-401e-4f0f-ba35-062cbadffa8f", "reportDate": "2016-06-11", "overall": { "rating": "Requires impro
How to handle a dictionary value that is a list
Hi, All, I was trying to handle the value of "personRoles" in a part of json dictionary. Can anyone tell me various ways to handle this? Regards, Shao "regulatedActivities": [ { "name": "Accommodation for persons who require nursing or personal care", "code": "RA2", "contacts": [ { "personTitle": "Mr", "personGivenName": "Steven", "personFamilyName": "Great", "personRoles": [ "Registered Manager" ] e,f = [],[] for result in d['regulatedActivities']: e.append(result['name']) for s in result['contacts']['personRoles']: t = (list) print s ###f.append(s) f = d['regulatedActivities']['contacts']['personRoles'] df1 = pd.DataFrame([e,f]).T -- https://mail.python.org/mailman/listinfo/python-list
Re: ValueError: arrays must all be same length
Hi, I managed to flatten it with json_normalize first. from pandas.io.json import json_normalize atable = json_normalize(d) atable Then, I got this table. brandId brandName careHome constituency currentRatings.overall.keyQuestionRatings currentRatings.overall.rating currentRatings.overall.reportDate currentRatings.overall.reportLinkId currentRatings.reportDate dormancy ... providerId region registrationDate registrationStatus regulatedActivities relationships reports specialisms type uprn 0 BD510 BRAND MACC Care Y Birmingham, Northfield [{u'reportDate': u'2020-10-01', u'rating': u'R... Requires improvement 2020-10-01 1157c975-c2f1-423e-a2b4-66901779e014 2020-10-01 N ... 1-101641521 West Midlands 2013-12-16 Registered [{u'code': u'RA2', u'name': u'Accommodation Then, I tried to expand the column of currentRatings.overall.keyQuestionRatings, with mydf = pd.DataFrame.from_dict(atable['currentRatings.overall.keyQuestionRatings'][0]) mydf Then, I got another table. name rating reportDate reportLinkId 0 Safe Requires improvement 2020-10-01 1157c975-c2f1-423e-a2b4-66901779e014 1 Well-led Requires improvement 2020-10-01 1157c975-c2f1-423e-a2b4-66901779e014 2 Caring Good 2019-10-04 63ff05ec-4d31-406e-83de-49a271cfdc43 3 Responsive Good 2019-10-04 63ff05ec-4d31-406e-83de-49a271cfdc43 4 Effective Requires improvement 2019-10-04 63ff05ec-4d31-406e-83de-49a271cfdc43 How can I re-arrange to get a flatten table? Apparently, the nested data is another table. Regards, Shao On Sun, 4 Oct 2020 at 13:55, Tim Williams wrote: > On Sun, Oct 4, 2020 at 8:39 AM Tim Williams wrote: > > > > > > > On Fri, Oct 2, 2020 at 11:00 AM Shaozhong SHI > > wrote: > > > >> Hello, > >> > >> I got a json response from an API and tried to use pandas to put data > into > >> a dataframe. > >> > >> However, I kept getting this ValueError: arrays must all be same length. > >> > >> Can anyone help? > >> > >> The following is the json text. Regards, Shao > >> > >> (snip json_text) > > > > > >> import pandas as pd > >> > >> import json > >> > >> j = json.JSONDecoder().decode(req.text) ###req.json > >> > >> df = pd.DataFrame.from_dict(j) > >> > > > > I copied json_text into a Jupyter notebook and got the same error trying > > to convert this into a pandas DataFrame:When I tried to copy this into a > > string, I got an error,, but without enclosing the paste in quotes, I got > > the dictionary. > > > > > (delete long response output) > > > > for k in json_text.keys(): > > if isinstance(json_text[k], list): > > print(k, len(json_text[k])) > > > > relationships 0 > > locationTypes 0 > > regulatedActivities 2 > > gacServiceTypes 1 > > inspectionCategories 1 > > specialisms 4 > > inspectionAreas 0 > > historicRatings 4 > > reports 5 > > > > HTH,. > > > > > This may also be more of a pandas issue. > > json.loads(json.dumps(json_text)) > > has a successful round-trip > > > > -- > >> https://mail.python.org/mailman/listinfo/python-list > >> > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Are there Python ways to execute queries on PostgreSQL without getting data over?
Are there Python ways to execute queries on PostgreSQL without getting data over? Are there ways just to fire off PostgreSQL queries and not get data into Python? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
How to expand and flatten a nested of list of dictionaries of varied lengths?
Even worse is that, in some cases, an addition called serviceRatings as a key occur with new data unexpectedly. How to produce a robust Python/Panda script to coping with all these? Regards, David u'historicRatings': [{u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Requires improvement'}, {u'name': u'Well-led', u'rating': u'Requires improvement'}], u'rating': u'Requires improvement'}, u'reportDate': u'2019-10-04', u'reportLinkId': u'63ff05ec-4d31-406e-83de-49a271cfdc43'}, {u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Good'}, {u'name': u'Well-led', u'rating': u'Good'}, {u'name': u'Caring', u'rating': u'Good'}, {u'name': u'Responsive', u'rating': u'Good'}, {u'name': u'Effective', u'rating': u'Requires improvement'}], u'rating': u'Good'}, u'reportDate': u'2017-09-08', u'reportLinkId': u'4f20da40-89a4-4c45-a7f9-bfd52b48f286'}, {u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Requires improvement'}, {u'name': u'Well-led', u'rating': u'Requires improvement'}, {u'name': u'Caring', u'rating': u'Requires improvement'}, {u'name': u'Responsive', u'rating': u'Requires improvement'}, {u'name': u'Effective', u'rating': u'Good'}], u'rating': u'Requires improvement'}, u'reportDate': u'2016-06-11', u'reportLinkId': u'0cc4226b-401e-4f0f-ba35-062cbadffa8f'}, {u'overall': {u'keyQuestionRatings': [{u'name': u'Safe', u'rating': u'Good'}, {u'name': u'Well-led', u'rating': u'Good'}, {u'name': u'Caring', u'rating': u'Good'}, {u'name': u'Responsive', u'rating': u'Requires improvement'}, {u'name': u'Effective', u'rating': u'Good'}], u'rating': u'Good'}, u'reportDate': u'2015-01-12', u'reportLinkId': u'a11c1e52-ddfd-4cd8-8b56-1b96ac287c96'}] -- https://mail.python.org/mailman/listinfo/python-list
How to write differently to remove this type hint in Python 2.7?
Is there another way to do this? def greet(name: str) -> str: return "Hello, " + name greet File "", line 1 def greet(name: str) -> str: ^ SyntaxError: invalid syntax -- https://mail.python.org/mailman/listinfo/python-list
Dataframe to postgresql - Saving the dataframe to memory using StringIO
I found this last option is very interesting. Saving the dataframe to memory using StringIO https://naysan.ca/2020/06/21/pandas-to-postgresql-using-psycopg2-copy_from/ But, testing shows unicode argument expected, got 'str' Any working example for getting DataFrame into a PostgreSQL table directly? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Re: Questions about XML processing?
Hi, Hernan, Did you try to parse GML? Surely, there can be very concise and smart ways to do these things. Regards, David On Fri, 6 Nov 2020 at 20:57, Hernán De Angelis wrote: > Thank you Terry, Dan and Dieter for encouraging me to post here. I have > already solved the problem albeit with a not so efficient solution. > Perhaps, it is useful to present it here anyway in case some light can > be added to this. > > My job is to parse a complicated XML (iso metadata) and pick up values > of certain fields in certain conditions. This goes for the most part > well. I am working with xml.etree.elementtree, which proved sufficient > for the most part and the rest of the project. JSON is not an option > within this project. > > The specific trouble was in this section, itself the child of a more > complicated parent: (for simplicity tags are renamed and namespaces > removed) > > > > > Something > > > Something else > > > > > value > > > > > 2020-11-06 > > > > > > > > > > > > Basically, I have to get what is in tagC/string but only if the value of > tagC/note/title/string is "value". As you see, there are several tagC, > all children of tagB, but tagC can have different meanings(!). And no, I > have no control over how these XML fields are constructed. > > In principle it is easy to make a "findall" and get strings for tagC, > using: > > elem.findall("./tagA/tagB/tagC/string") > > and then get the content and append in case there is more than one > tagC/string like: "Something, Something else". > > However, the hard thing to do here is to get those only when > tagC/note/title/string='value'. I was expecting to find a way of > specifying a certain construction in square brackets, like > [@string='value'] or [@/tagC/note/title/string='value'], as is usual in > XML and possible in xml.etree. However this proved difficult (at least > for me). So this is the "brute" solution I implemented: > > - find all children of tagA/tagB > - check if /tagA/tagB/tagC/note/title/string has "value" > - if yes find all tagA/tagB/tagC/string > > In quasi-Python: > > string = [] > element0 = elem.findall("./tagA/tagB/") > for element1 in element0: > element2 = element1.find("./tagA/tagB/tagC/note/title/string") > if element2.text == 'value' > element3 = element1.findall("./tagA/tagB/tagC/string) > for element4 in element3: > string.append(element4.text) > > > Crude, but works. As I wrote above, I was wishing that a bracketed > clause of the type [@ ...] already in the first "findall" would do a > more efficient job but alas my knowledge of xml is too rudimentary. > Perhaps something to tinker on in the coming weeks. > > Have a nice weekend! > > > > > > On 2020-11-06 20:10, Terry Reedy wrote: > > On 11/6/2020 11:17 AM, Hernán De Angelis wrote: > >> I am confronting some XML parsing challenges and would like to ask > >> some questions to more knowledgeable Python users. Apparently there > >> exists a group for such questions but that list (xml-sig) has > >> apparently not received (or archived) posts since May 2018(!). I > >> wonder if there are other list or forum for Python XML questions, or > >> if this list would be fine for that. > > > > If you don't hear otherwise, try here. Or try stackoverflow.com and > > tag questions with python and xml. > > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
ssl connection has been closed unexpectedly
Hi, I keep getting the following error when I use engine = create_engine(logging in details to postgres) df.to_sql('table_name', and etc.) OperationalError: (psycopg2.OperationalError) SSL connection has been closed unexpectedly (Background on this error at: http://sqlalche.me/e/13/e3q8) OperationalError: (psycopg2.OperationalError) SSL connection has been closed unexpectedly Can anyone shed any light on this? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
How to record full error message for debugging with nbconvert?
Hi, When I use nbconvert to run Jupyter notebook, it is so difficult to see the full error message for debugging? How to save full error messages? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
How to run Jupyter notebook in command line and get full error message?
How to run Jupyter notebook in command line and get full error messages? My VPN keeps dropping and can not run Jupyter Notebook as it is. I started to use nbconvert in command line. But, when it stops due to error, I can not see where the error occurs. In order to make life easier for debugging, what is the best practice? Regards, David -- https://mail.python.org/mailman/listinfo/python-list
Observing long running processes of Jupyter Notebook
We have been running Jupyter Notebook processes, which take long time to run. We use nbconvert to run these in commandline. Nbconvert only writes output into a file at the end. We just wonder whether there is a way to observe the progress and printing messages when nbconvert is running. Regards, David -- https://mail.python.org/mailman/listinfo/python-list
divide
I have three points in a rectangle and i wonder how to use PYTHON to divide the rectangle into three parts with each point located in the different part. For instance, Point A goes to Part I, Point B goes to Part II and Point C goes to Part III. And the distance between any point within Part I and Point A is smaller than to Point B and Point C. And the similar rule applies to Part II and Part III. Thanks for any idea. -- http://mail.python.org/mailman/listinfo/python-list
is there any Python code for spatial tessellation?
is there any Python code for spatial tessellation? thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list
Re: is there any Python code for spatial tessellation?
is there any course website about teaching python? for instance, some computer science courses website? On 10/8/05, Shi Mu <[EMAIL PROTECTED]> wrote: > is there any Python code for spatial tessellation? > thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list
line
There are four points with coordinates: 2,3;4,9;1,6;3,10. How to use Python to draw one perpendicular bisector between (2,3) and (4,9); the other perpendicular bisector between (1,6)和(3,10); then, makes the output like: l1 a b c l2 a b c (Note: l indicates the perpendicular bisector with equation ax + by = c.) Plus the intersection coordinates of the two perpendicular bisectors: x,y -- http://mail.python.org/mailman/listinfo/python-list
Re: line
it is not a homework, just interested. On 10 Oct 2005 00:04:23 -0700, gsteff <[EMAIL PROTECTED]> wrote: > Why do you want to know? This list isn't a tool to get others to do > your homework. > > Greg > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
output
After I run the following python code, I expect to have the printing such as: The year is 2005 However, I got something like: The year is 2005 Fri Oct 14 17:43:31 2005 Fri Oct 14 17:43:31 2005 The year is 2005 What is the reason? The code follows: import time import now class today(now.now): def __init__(self, y = 1970): now.now.__init__(self) def update(self,tt): if len(tt) < 9 : raise TypeError if tt[0] < 1970 or tt[0] > 2038: raise OverflowError self.t = time.mktime(tt) self(self.t) if __name__ == "__main__": n = today() print "The year is", n.year -- http://mail.python.org/mailman/listinfo/python-list
path
I have installed Python 2.3 and I type "help()" and then "Keywords". I get a list of words. And it says that I can enter any of the words to get more help. I enter "and" and I get the following error message: "Sorry, topic and keyword documentation is not available because the Python HTML documentation files could not be found. If you have installed them, please set the environment variable PYTHONDOCS to indicate their location." but I have set both the environment variable, with the path to be C:\Python23\Doc which includes python23.chm Why I still got the above error message? -- http://mail.python.org/mailman/listinfo/python-list
path
I have installed Python 2.3 and I type "help()" and then "Keywords". I get a list of words. And it says that I can enter any of the words to get more help. I enter "and" and I get the following error message: "Sorry, topic and keyword documentation is not available because the Python HTML documentation files could not be found. If you have installed them, please set the environment variable PYTHONDOCS to indicate their location." but I have set both the environment variable, with the path to be C:\Python23\Doc which includes python23.chm Why I still got the above error message? -- http://mail.python.org/mailman/listinfo/python-list
Re: path
what is the differenc ebetween index and find in the module of string? for both "find" and "index", I got the position of the letter. -- http://mail.python.org/mailman/listinfo/python-list
index and find
what is the difference between index and find in the module of string? for both "find" and "index", I got the position of the letter. On 10/19/05, Shi Mu <[EMAIL PROTECTED]> wrote: > I have installed Python 2.3 and I type "help()" and then "Keywords". > I get a list of words. And it says that I can enter any of the words > to get more help. I enter > "and" and I get the following error message: > "Sorry, topic and keyword documentation is not available because the Python > HTML documentation files could not be found. If you have installed them, > please set the environment variable PYTHONDOCS to indicate their location." > > but I have set both the environment variable, with the path to be > C:\Python23\Doc which includes python23.chm > Why I still got the above error message? > -- http://mail.python.org/mailman/listinfo/python-list
ABOUT FIND
I got confused by the following information from the help for "FIND": find(s, *args) find(s, sub [,start [,end]]) -> in what does *args mean (especially the '*')? also, in the sub, why put a comma before start? what does 'in' mean? -- http://mail.python.org/mailman/listinfo/python-list
Print in PythonWin
In the PythonWin's interactive window, why sometimes I need type the command two times to make it work? for example, I execute "print testList" two times to make it work. Why? >>> print testList >>> print testList ['w', 'e', ' ', 'w', 'a', 'n', 't', ' ', 't', 'o', ' ', 'l', 'e', 'a', 'r', 'n', ' ', 'p', 'y', 't', 'h', 'o', 'n'] -- http://mail.python.org/mailman/listinfo/python-list
difference after remove
Is there any difference if I remove the '/' from the following statement? intMatrix2 = [[1,1,2,4,1,7,1,7,6,9],\ [1,2,5,3,9,1,1,1,9,1],\ [0,0,5,1,1,1,9,7,7,7]] print intMatrix2 I removed one '\' and it still works. So what is the use of '\'? -- http://mail.python.org/mailman/listinfo/python-list
pickle
I got a sample code and tested it but really can not understand the use of pickle and dump: >>> import pickle >>> f = open("try.txt", "w") >>> pickle.dump(3.14, f) >>> pickle.dump([1,2,3,4], f) >>> f.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: pickle
what does the following code mean? y = pickle.load(file("cnumber.pickle", "r")) also, I can not understand "f" in pickle.dump(x, f) On 10/25/05, marduk <[EMAIL PROTECTED]> wrote: > On Mon, 2005-10-24 at 23:55 -0700, Shi Mu wrote: > > I got a sample code and tested it but really can not understand the > > use of pickle and dump: > > > > >>> import pickle > > >>> f = open("try.txt", "w") > > >>> pickle.dump(3.14, f) > > >>> pickle.dump([1,2,3,4], f) > > >>> f.close() > > The pickle module "serializes" python objects. You can "dump" a python > object that can later be loaded: > > >>> x = complex(2,3.5) > >>> f = open("cnumber.pickle", "w") > >>> import pickle > >>> pickle.dump(x, f) > >>> f.close() > >>> y = pickle.load(file("cnumber.pickle", "r")) > >>> y > (2+3.5j) > > > -- http://mail.python.org/mailman/listinfo/python-list
cell and row
I can not understand the use of "cell" and "row" in the code: # convert the matrix to a 1D list matrix = [[13,2,3,4,5],[0,10,6,0,0],[7,0,0,0,9]] items = [cell for row in matrix for cell in row] print items -- http://mail.python.org/mailman/listinfo/python-list
Re: cell and row
In the follwoing code, Why the result is "'defenestrate', 'window', 'defenestrate', " before the original list instead of 'defenestrate', 'window', ? >>> a = ['defenestrate', 'cat', 'window', 'defenestrate'] >>> for x in a[:]: ... if len(x) > 4: a.insert(0, x) ... >>> a ['defenestrate', 'window', 'defenestrate', 'defenestrate', 'cat', 'window', 'defenestrate'] On 10/25/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > >I can not understand the use of "cell" and "row" in the code: > > > > # convert the matrix to a 1D list > > matrix = [[13,2,3,4,5],[0,10,6,0,0],[7,0,0,0,9]] > > items = [cell for row in matrix for cell in row] > > print items > > working through the Python tutorial might be a good idea. here's the section > on list comprehensions: > > http://docs.python.org/tut/node7.html#SECTION00714 > > and here's the section on for loops: > > http://docs.python.org/tut/node6.html#SECTION00620 > > briefly: > >items = [cell for row in matrix for cell in row] > > or, slightly edited for clarity: > >items = [(cell) >for row in matrix >for cell in row] > > is the same thing as: > >items = [] >for row in matrix: >for cell in row: >items.append(cell) > > except that it's a bit shorter, and a bit more efficient. > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Tk
When I run the following code, script kept running and I have to force it to stop. Could you check the code to give suggestions how to improve it? Thanks a lot! from Tkinter import * from Tkinter import _cnfmerge class Dialog(Widget): def __init__(self, master=None, cnf={}, **kw): cnf = _cnfmerge((cnf, kw)) self.widgetName = '__dialog__' Widget._setup(self, master, cnf) self.num = self.tk.getint( apply(self.tk.call, ('tk_dialog', self._w, cnf['title'], cnf['text'], cnf['bitmap'], cnf['default']) + cnf['strings'])) try: Widget.destroy(self) except TclError: pass def destroy(self): pass if __name__ == '__main__': q = Button(None, {'text': 'How are you', Pack: {}}) b1 = Listbox() b1.pack() c1 = Checkbutton(text="Check") c1.pack() q.mainloop() from Tkinter import * root =Tk() menu=Menu(root) root.config(menu=menu) filemenu=Menu(menu) menu.add_cascade(label="Test", menu=filemenu) filemenu.add_command(label="Just Try") filemenu.add_separator() mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Tk
How can I make the main menu come first, and after clicking test/just try, "how are you" interface shows. Thanks a lot! from Tkinter import * from Tkinter import _cnfmerge class Dialog(Widget): def __init__(self, master=None, cnf={}, **kw): cnf = _cnfmerge((cnf, kw)) self.widgetName = '__dialog__' Widget._setup(self, master, cnf) self.num = self.tk.getint( apply(self.tk.call, ('tk_dialog', self._w, cnf['title'], cnf['text'], cnf['bitmap'], cnf['default']) + cnf['strings'])) try: Widget.destroy(self) except TclError: pass def destroy(self): pass if __name__ == '__main__': q = Button(None, {'text': 'How are you', Pack: {}}) b1 = Listbox() b1.pack() c1 = Checkbutton(text="Check") c1.pack() q.mainloop() from Tkinter import * root =Tk() menu=Menu(root) root.config(menu=menu) filemenu=Menu(menu) menu.add_cascade(label="Test", menu=filemenu) filemenu.add_command(label="Just Try") filemenu.add_separator() mainloop() -- http://mail.python.org/mailman/listinfo/python-list
click event
I have the following workable code and every time i click on the canvas, the coordinates are reported. i wonder how i can draw the lines when i click the canvas using these coordinates? from Tkinter import * root = Tk() c = Canvas(root, bg='#0e2e0e', height=500, width=1000) def click(event): print event.x, event.y frame = c c.bind('',click) c.pack() root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
image
why the following code report the error: Traceback (most recent call last): File "C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\Python23\Examples\AppB\text.py", line 24, in ? text.image_create(END, image=photo) File "C:\Python23\lib\lib-tk\Tkinter.py", line 2882, in image_create return self.tk.call( TclError: image "pyimage4" doesn't exist from Tkinter import * root = Tk() root.option_readfile('optionDB') root.title('Text') text = Text(root, height=26, width=50) scroll = Scrollbar(root, command=text.yview) text.configure(yscrollcommand=scroll.set) text.tag_configure('bold_italics', font=('Verdana', 12, 'bold', 'italic')) text.tag_configure('big', font=('Verdana', 24, 'bold')) text.tag_configure('color', foreground='blue', font=('Tempus Sans ITC', 14)) text.tag_configure('groove', relief=GROOVE, borderwidth=2) text.tag_bind('bite', '<1>', lambda e, t=text: t.insert(END, "I'll bite your legs off!")) text.insert(END, 'Something up with my banter, chaps?\n') text.insert(END, 'Four hours to bury a cat?\n', 'bold_italics') text.insert(END, 'Can I call you "Frank"?\n', 'big') text.insert(END, "What's happening Thursday then?\n", 'color') text.insert(END, 'Did you write this symphony in the shed?\n', 'groove') button = Button(text, text='I do live at 46 Horton terrace') text.window_create(END, window=button) photo=PhotoImage(file='img52.gif') text.image_create(END, image=photo) text.insert(END, 'I dare you to click on this\n', 'bite') text.pack(side=LEFT) scroll.pack(side=RIGHT, fill=Y) root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: image
yes. I use both cmd and pythonwin to run it. why both of them can not work? On 11/8/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > > why the following code report the error: > > Traceback (most recent call last): > > File > > "C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", > > line 310, in RunScript > >exec codeObject in __main__.__dict__ > > File "C:\Python23\Examples\AppB\text.py", line 24, in ? > >text.image_create(END, image=photo) > > File "C:\Python23\lib\lib-tk\Tkinter.py", line 2882, in image_create > >return self.tk.call( > > TclError: image "pyimage4" doesn't exist > > works for me, when running it from a stock CPython interpreter. > > have you tried running the script outside the pywin environment? > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
any python module to calculate sin, cos, arctan?
any python module to calculate sin, cos, arctan? -- http://mail.python.org/mailman/listinfo/python-list
parabola
Is there any sample code to draw parabola using Tkinter? -- http://mail.python.org/mailman/listinfo/python-list
triangulation
is there any sample code to triangulation? many thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: triangulation
Delaunay triangulations On 11/9/05, Robert Kern <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > is there any sample code to triangulation? many thanks! > > Triangulation of what? Scattered points in a plane? 2D manifolds > embedded in a 3D space? > > Delaunay triangulations? Constrained triangulations? > > -- > Robert Kern > [EMAIL PROTECTED] > > "In the fields of hell where the grass grows high > Are the graves of dreams allowed to die." > -- Richard Harter > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] triangulation
On 11/10/05, Alex Hunsley <[EMAIL PROTECTED]> wrote: > Alan Gauld wrote: > > >>As in Pythagoras? > >> > >> > > > > > > > >>Or as in triangulation on a 2D surface, navigation etc.? > >> > >> > > > > > > > >>Or, do you mean radio triangulation by directional signal propagation > >> > >> > > > > > > > >>Or, do you mean drawing a triangle in Tkinter? > >> > >> > > > >Or even triangulation of currency from EU currency to EU currency > >via the euro? > > > >See: > >http://www.sysmod.com/eurofaq.htm#Triangulation > > > >Alan G. > > > > > This Shi Mu character is a little frustrating. They won't even respond > to peoples polite responses for clarification > Hit'n'run help requests. > > > the Internet is down for one day and so wonderful to have so many responses. i have checked all the links you guys mentioned. what i want is delaunay triangulation and the available ones online are written in C, Java and FORTRAN. I want to see some in Python because it is hard for me to figure out using python to do Fortune's sweeping line algorithm. Is python is not good in doing that kind of computation or some other reason? Thanks a lot for all of your responses!!! -- http://mail.python.org/mailman/listinfo/python-list
about widget construction kit
I tried to install WCK(Widget Construction Kit (WCK)): C:\Python23>python tkinter3000-1.0-20031212\setup.py install Traceback (most recent call last): File "tkinter3000-1.0-20031212\setup.py", line 23, in ? WCK_VERSION = setuplib.find_version("WCK/__init__.py") File "C:\wget2\tkinter3000-1.0-20031212\setuplib.py", line 74, in find_version for line in open(filename).readlines(): IOError: [Errno 2] No such file or directory: 'WCK/__init__.py' I checked my files and found there is a __init__.py and got confused why the error came out? On 11/11/05, Salvatore Di Dio <[EMAIL PROTECTED]> wrote: > If you mean trigonometrics calculus > give a try at > http://online.effbot.org/2004_09_01_archive.htm#tkinter-complex > and download too WCK http://effbot.org/zone/tkinter-index.htm > there is a demo on Lissajou > > Regards > > Shi Mu a écrit : > > >is there any sample code to triangulation? many thanks! > > > > > > > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: about widget construction kit
On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > > I tried to install WCK(Widget Construction Kit (WCK)): > > > > C:\Python23>python tkinter3000-1.0-20031212\setup.py install > > Traceback (most recent call last): > > File "tkinter3000-1.0-20031212\setup.py", line 23, in ? > > WCK_VERSION = setuplib.find_version("WCK/__init__.py") > > File "C:\wget2\tkinter3000-1.0-20031212\setuplib.py", line 74, in > > find_version > > for line in open(filename).readlines(): > > IOError: [Errno 2] No such file or directory: 'WCK/__init__.py' > > > > I checked my files and found there is a __init__.py and got confused > > why the error came out? > > if you're using windows, please use a prebuilt version of the WCK. > > I also recommend using the 1.1b1 release; it's a lot better than 1.0. > > if you really want to build it yourself, and you have the right compilers > and all Tcl/Tk build files in the right places, change to the source directory > before running the setup script. if I run python command, I need to go to the directory where python is installed, so how can I change to the source directory at the same time? -- http://mail.python.org/mailman/listinfo/python-list
Re: directory listing
On 11 Nov 2005 22:00:04 GMT, Michael Konrad <[EMAIL PROTECTED]> wrote: > Richard Townsend <[EMAIL PROTECTED]> wrote: > > > On 11 Nov 2005 21:20:33 GMT, SU News Server wrote: > > > > Try passing the full pathname of each item to os.path.isdir() > > > > You can create the pathname using os.path.join(directory, x) > > > > > > > > I wonder if I can join ./, so I don't have the full path in each > entry? > > Thank you for responding. > _Michael > > > -- > http://mail.python.org/mailman/listinfo/python-list > I tried this and no error reported but nothing appear on the console, why? import os def buildList( directory='c:\TEMP' ): dirs = [ ] listing = os.listdir(directory) for x in listing: x = os.path.join(directory, x) print x if os.path.isdir(x): dirs.append(x) return dirs -- http://mail.python.org/mailman/listinfo/python-list
Re: directory listing
On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > > I tried this and no error reported but nothing appear on the console, why? > > > > import os > > > > def buildList( directory='c:\TEMP' ): > > dirs = [ ] > > listing = os.listdir(directory) > > for x in listing: > > x = os.path.join(directory, x) > > print x > > if os.path.isdir(x): > > dirs.append(x) > > return dirs > > is that the entire script? you're defining a function, but you're > not calling it. try adding > >print buildList() > > at the end of the script. It works but i am curious why the line of "print x" does not show anything. many thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: about widget construction kit
On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > > > > I tried to install WCK(Widget Construction Kit (WCK)): > > > > > > > > C:\Python23>python tkinter3000-1.0-20031212\setup.py install > > > > Traceback (most recent call last): > > > > File "tkinter3000-1.0-20031212\setup.py", line 23, in ? > > > > WCK_VERSION = setuplib.find_version("WCK/__init__.py") > > > > File "C:\wget2\tkinter3000-1.0-20031212\setuplib.py", line 74, in > > > > find_version > > > > for line in open(filename).readlines(): > > > > IOError: [Errno 2] No such file or directory: 'WCK/__init__.py' > > > > > > > > I checked my files and found there is a __init__.py and got confused > > > > why the error came out? > > > > > > if you're using windows, please use a prebuilt version of the WCK. > > > > > > I also recommend using the 1.1b1 release; it's a lot better than 1.0. > > > > > > if you really want to build it yourself, and you have the right compilers > > > and all Tcl/Tk build files in the right places, change to the source > > > directory > > > before running the setup script. > > > if I run python command, I need to go > > to the directory where python is installed, so how can I change to the > > source directory at the same time? > > you're 100% sure that you have a working compiler and the right Tcl/Tk > build files in the right place, but you don't know how to run an executable > from another directory? > > hmm. > > here are three ways: > > 1. pass in the full path to the executable: > >cd tkinter3000-1.0-20031212 >c:\python23\python setup.py install > > 2. add the python installation directory to the path. random > google link: > >http://www.computerhope.com/issues/ch000549.htm > > when you've updated the environment, open up a new command > window, and do > >cd tkinter3000-1.0-20031212 >python setup.py install > > 3. if you used a python.org installer, it's likely that you can run > the setup.py file directly: > >cd tkinter3000-1.0-20031212 >setup.py install > still confused by th first way you mentioned. If I cd tkinter3000-1.0-20031212, i will be enter the directory witht hte setup.py; for example, it is located as c:\temp\tkinter3000-1.0-20031212\setup.py However, I need to use c:\python23\python setup.py install to process the installation, how did python know where the file of "setup.py" located? -- http://mail.python.org/mailman/listinfo/python-list
Re: directory listing
On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > "Shi Mu" wrote: > > > but i am curious why the line of "print x" does not show > > anything. > > because your c:\temp directory is empty ? > > print buildList() gets lots of stuffs from my temp directory(there do exist lots of files). But why "print x' has nothing? -- http://mail.python.org/mailman/listinfo/python-list
x, y coordinates in Tkinter canvas
got confused by x, y coordinates in Tkinter canvas. from left to right, does X increase? from top to bottom, does y increase? -- http://mail.python.org/mailman/listinfo/python-list
Re: about widget construction kit
On 11 Nov 2005 16:06:37 -0800, Martin Miller <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > 1. pass in the full path to the executable: > > > > > >cd tkinter3000-1.0-20031212 > > >c:\python23\python setup.py install > > > ... > > > > > still confused by th first way you mentioned. If I cd > > tkinter3000-1.0-20031212, i will be enter the directory witht hte > > setup.py; for example, it is located as > > c:\temp\tkinter3000-1.0-20031212\setup.py > > However, I need to use c:\python23\python setup.py install to process > > the installation, how did python know where the file of "setup.py" > > located? > > Since a full path was not given for the 'setup.py' file in the second > line, it will be assumed to be in the current directory which was set > by the 'cd' command in the first line. > > HTH I tried again and got the follwoing message: *** cannot find Tcl/Tk headers and library files change the TCL_ROOT variable in the setup.py file but i have already installed TCL under python23 -- http://mail.python.org/mailman/listinfo/python-list
Re: about widget construction kit
very hard for me to understand the difference between try...except and try...finally -- http://mail.python.org/mailman/listinfo/python-list
about try statement
very hard for me to understand the difference between try...except and try...finally -- http://mail.python.org/mailman/listinfo/python-list
about array,arange
i got confused by the use of array and arange. arange get array and range get list, why we need the two different types? -- http://mail.python.org/mailman/listinfo/python-list
Re: about array,arange
On 11/12/05, Robert Kern <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > i got confused by the use of array and arange. > > arange get array and range get list, why we need the two different types? > > When you're asking questions about a third-party module, it's a good > idea to mention the module. In this case you're asking about scipy_core > (hopefully) or else numarray or Numeric. > > The answer to your question is that sometimes we need to get largish > arrays (not lists) of consecutive numbers quickly. array(range(N)) is > wasteful of memory and time because it has to create a list of Python > ints that are simply going to be thrown away once we're done converting > to the needed array. > > -- > Robert Kern > [EMAIL PROTECTED] sorry to forget to mention the module name : Numeric -- http://mail.python.org/mailman/listinfo/python-list