Re: Reply to author, reply to list, reply to all
Nick Sarbicki writes: > My question then is do you reply to all (with a clean cc list but > including an OP from outside the list) in response to a persons > question If the question was addressed to this forum, then answering the question should also be addressed to this forum. So: reply to list. > even if the question is relatively simple. I don't think the simplicity of the question changes the above. > For me it's appreciated so that you know someone is dealing with it. If you're asking a question in a public discussion forum (such as this one), then to see the ensuing dicussion you need to subscribe. > But then it can also result in flooding your inbox. If you don't want that, then don't have them delivered to your inbox. You can, for example, filter messages that are part of this forum to a separate mailbox; or you can subscribe using a non-email method such as NNTP. -- \ “Courage is not the absence of fear, but the decision that | `\ something else is more important than fear.” —Ambrose Redmoon | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Reply to author, reply to list, reply to all (was: Need Help w. PIP!)
On Wed, Sep 9, 2015 at 4:37 PM, Nick Sarbicki wrote: > My question then is do you reply to all (with a clean cc list but including > an OP from outside the list) in response to a persons question, even if the > question is relatively simple. > > For me it's appreciated so that you know someone is dealing with it. But > then it can also result in flooding your inbox. Personally, what I do (which I'm doing with this post) is to use Gmail's "reply-all" feature, and then manually delete the individual addresses. Sometimes, half way through writing up a post, I decide to send it privately rather than to the list, and then I delete the list rather than the author. (Not usually with this list, though; more often with Savoynet, where private replies are more common, and there's no newsgroup equivalence.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Reply to author, reply to list, reply to all
Chris Angelico writes: > Personally, what I do (which I'm doing with this post) is to use > Gmail's "reply-all" feature, and then manually delete the individual > addresses. That is testimony in support of the position that Google Mail is a poorly-designed interface for discussion forums such as mailing lists. Google Mail, like any other mail client, has full access to all the technical information (specified in RFC 3696) needed to implement a correct “reply to list” behaviour. Users shouldn't need to do anything tediously manual like you describe, they should be presented with an obvious “reply to the same place” function, as implemented in many mail clients for over a decade. That Google Mail continues to fail in this regard is something its users need to apply pressure to fix, or choose better mail clients until it improves. -- \ “Anyone who believes exponential growth can go on forever in a | `\finite world is either a madman or an economist.” —Kenneth | _o__) Boulding | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On Tue, 08 Sep 2015 23:35:33 +0100, Mark Lawrence wrote: > On 08/09/2015 20:14, Laszlo Lebrun via Python-list wrote: >> >> Dear group, >> I do use Windows 7 and have a user name with diacritics. >> >> Whenever I am querying an extension with pip, it will fail since it >> does not pass on the user folder correctly. >> I thought PIP deals well with unicode, doesn't it? >> >> Has anyone a clue how to fix it? >> Thank you >> >> > Can you please cut and paste exactly what you tried and the failure > messages, as there's a lot of smart people around here but we're not > mind readers :) Which Python and pip version are you using? Did you > install pip yourself or did it come with your Python installation? Yes, you are right, let me append the message. Just after a fresh install of Python with PIP on Windows. Whenever I start PIP, I get: "Fatal error in launcher: Unable to create process using '"C:\Users \B├╝rgerGegenFlugl├ñrm\AppData\Local\Programs\Python\Python35-32 \python.exe" "C:\Users\B³rgerGegenFluglõrm\AppData\Local\Programs\Python \Python35-32\Scripts\pip.exe" '" Where the correct path is "C:\Users\BürgerGegenFluglärm\AppData..." The funny thing is that the message mentions the path twice, with different wrong codings. :-( Thank you for your help. -- Stand up against TTIP and ISDS ! -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On 09/09/2015 08:59, Laszlo Lebrun via Python-list wrote: > On Tue, 08 Sep 2015 23:35:33 +0100, Mark Lawrence wrote: > >> On 08/09/2015 20:14, Laszlo Lebrun via Python-list wrote: >>> >>> Dear group, >>> I do use Windows 7 and have a user name with diacritics. >>> >>> Whenever I am querying an extension with pip, it will fail since it >>> does not pass on the user folder correctly. >>> I thought PIP deals well with unicode, doesn't it? > Yes, you are right, let me append the message. > Just after a fresh install of Python with PIP on Windows. > Whenever I start PIP, I get: > "Fatal error in launcher: Unable to create process using '"C:\Users > \B├╝rgerGegenFlugl├ñrm\AppData\Local\Programs\Python\Python35-32 > \python.exe" "C:\Users\B³rgerGegenFluglõrm\AppData\Local\Programs\Python > \Python35-32\Scripts\pip.exe" '" > > Where the correct path is "C:\Users\BürgerGegenFluglärm\AppData..." > > The funny thing is that the message mentions the path twice, with > different wrong codings. > :-( > What version of pip are you using? Since (from the path) I guess you have a 32-bit version of Python 3.5, I assume it's the version which was installed with that but just check: pip --version Hopefully someone here can help, but in fact pip is not part of core Python: the ensurepip mechanism (which *is* part of core Python) bootstraps a recent version of pip but it's maintained elsewhere. So you may need to raise this as a bug on the Pip tracker: https://github.com/pypa/pip/issues TJG -- https://mail.python.org/mailman/listinfo/python-list
Re: Reply to author, reply to list, reply to all
On 9/9/2015 2:09 AM, Ben Finney wrote: Terry Reedy writes: [Reply] should send the reply to the list. The function named “reply” normally means “reply individually to the author”, and that's how it needs to stay. Oh, right. I was thinking of 'Followup' and that should go to the list, and does for me. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: XML Binding
Palpandi writes: > Is it better to use pyxb than lxml? > > What are the advantages of lxml and pyxb? "pyxb" has a different aim than "lxml". "lxml" is a general purpose library to process XML documents. It gives you an interface to the document's resources (elements, attributes, comments, processing instructions) on a low level independ from the document type. "pyxb" is different: there, you start with an XML schema description. You use "pyxb" to generate Python bindings for this schema. With such a binding generated, "pyxb" can parse XML documents following a known XML schema into the corresponding binding. The binding objects expose child (XML) elements and (XML) attributes as attributes of the binding object. Thus, the Python interface (as defined by the binding) is highly dependent on the type (aka XML schema) of the document. I use "lxml" for either simple XML processing or when the XML documents are not described by an XML schema. I use "pyxb" when the XML documents has an associated complex schema and the processing is rather complex. -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On Wed, Sep 9, 2015 at 5:59 PM, Laszlo Lebrun via Python-list
wrote:
> Whenever I start PIP, I get:
> "Fatal error in launcher: Unable to create process using '"C:\Users
> \BürgerGegenFluglärm\AppData\Local\Programs\Python\Python35-32
> \python.exe" "C:\Users\B³rgerGegenFluglõrm\AppData\Local\Programs\Python
> \Python35-32\Scripts\pip.exe" '"
>
> Where the correct path is "C:\Users\BürgerGegenFluglärm\AppData..."
>
> The funny thing is that the message mentions the path twice, with
> different wrong codings.
> :-(
Peculiar. I don't know if it helps, but the first one seems to have
been encoded UTF-8 and then decoded CP437; and the second has been
encoded Latin-1 and decoded CP850.
>>> "BürgerGegenFluglärm".encode("utf-8").decode("437")
'BürgerGegenFluglärm'
>>> "BürgerGegenFluglärm".encode("iso-8859-1").decode("850")
'B³rgerGegenFluglõrm'
But why those particular encodings... weird.
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
From logging to files to a better solution: syslog, Sentry, Logstash, ....
Up to now we use simple logging to files. We don't use syslog or an other server based solution. I am unsure which architecture works for our environment. Our environment: - django based applications - a lot of batch/cron jobs (non web gui) processing - One linux server runs several systems. Each system has its own virtualenv. - servers are running in the intranet of our customers. - We have access via VPN, but it is slow. And sometimes down for some minutes. - 40MByte logs per day per server. Why we are unhappy with logging to files: - filtering: We don't want to get INFO messages over the VPN. Background: Sometimes a there is too much logging and we don't want to pull gigabytes over the VPN. - Rotating: Rotating files is possible, but somehow cumbersome. - Support structured logging of values (json) in the future. I have not locked at Sentry or Logstash in detail. Which solution could fit for our environment? Please ask if you have question! Regards, Thomas Güttler -- https://mail.python.org/mailman/listinfo/python-list
Re: issue while doing pexpect ssh
On Tuesday, 8 September 2015 17:07:24 UTC+5:30, [email protected] wrote: > Some where i am missing simple logic :) > > = > child = pexpect.spawn('ssh hari@hostname') > child.logfile = sys.stdout > child.expect('hari\'s Password: ') > = > > getting error as follows: > > child.expect('hari\'s Password: ') > TypeError: must be str, not bytes > === > > Thanks... Hey Laura, spawnu worked for handling the unicode, thank you for that, yes i have already tried paramiko, it didnt worked for the same purpose (tried both sftp client and ssh client of paramiko module; finally while doing su getting the error as expecting tty terminal...) fabric will work but it is up to only python 2.7 so just i am trying to work out with pexpect whether it will be of any use or not. (my goal is to login to remote server then do su then execute commands...) Thank you for spawnu, now i got stuck with freezing issue similar to it is not returing to the shell prompt...its on waiting...i had to press ctrl+c === child.sendline(password) child.expect('-bash-4.1$') child.sendline('ls') print(child.before) child.sendline('su - user1') child.expect('-bash-4.1$') child.sendline('pwd; hostname') print(child.before) child.close() = output: hari's Password: ls WARNING. You have accessed a private computer system. Unauthorized access,use,connection,or entry is not permitted and constitutes a crime punishable by law. We reserve the right to fully pursue criminal and civil legal penalties. All individuals using this computer system with or without proper authority are subject to having all their activities monitored and recorded. Anyone using this system implicitly consents to this monitoring. Any evidence of suspected criminal activity revealed by such monitoring may be provided to law enforcement officials. su - user1 lsTotal users logged in under your name (via BoKS): 3 (2 on this host) Total users logged in (via BoKS): 8324 (2 on this host) # # For Authorized Use Only # # # # Activities on this system are subject to being monitored# # or recorded for all users, authorized or unauthorized. # # Use of the system is considered consent to such monitoring. # # Any evidence of possible criminal activity may be provided # # to law enforcement. # # # # -bash-4.1$ ls -bash-4.1$ su - user1 -bash-4.1$ ^CTraceback (most recent call last): File "./rmcomments.py", line 16, in child.expect('-bash-4.1$') File "/ceopt/utils/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/__init__.py", line 1451, in expect timeout, searchwindowsize) File "/ceopt/utils/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/__init__.py", line 1466, in expect_list timeout, searchwindowsize) File "/ceopt/utils/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/__init__.py", line 1535, in expect_loop c = self.read_nonblocking(self.maxread, timeout) File "/ceopt/utils/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/__init__.py", line 958, in read_nonblocking r, w, e = self.__select([self.child_fd], [], [], timeout) File "/ceopt/utils/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/__init__.py", line 1717, in __select return select.select(iwtd, owtd, ewtd, timeout) KeyboardInterrupt -- https://mail.python.org/mailman/listinfo/python-list
Re: XML Binding
On Thursday, 3 September 2015 22:25:06 UTC+5:30, Palpandi wrote: > Hi All, > > Is there any module available in python standard library for XML binding? If > not, any other suggestions. > > Which is good for parsing large file? > 1. XML binding > 2. Creating our own classes > > > Thanks, > Palpandi Hey you can use internal package itself, argparse will work good...even xmltree also... -- https://mail.python.org/mailman/listinfo/python-list
Re: issue while doing pexpect ssh
On Tuesday, 8 September 2015 17:07:24 UTC+5:30, [email protected] wrote: > Some where i am missing simple logic :) > > = > child = pexpect.spawn('ssh hari@hostname') > child.logfile = sys.stdout > child.expect('hari\'s Password: ') > = > > getting error as follows: > > child.expect('hari\'s Password: ') > TypeError: must be str, not bytes > === > > Thanks... Hey All, I am able to achieve this using pxssh.. thank you for help... -- https://mail.python.org/mailman/listinfo/python-list
Re: XML Binding
dieter schrieb am 09.09.2015 um 10:20: > Palpandi writes: >> Is it better to use pyxb than lxml? >> >> What are the advantages of lxml and pyxb? > > "pyxb" has a different aim than "lxml". > > "lxml" is a general purpose library to process XML documents. > It gives you an interface to the document's resources (elements, > attributes, comments, processing instructions) on a low level > independ from the document type. lxml's toolbox is actually larger than that. There's also lxml.objectify which provides a Python object interface to the XML tree, similar to what data binding would give you. And you can stick your own Element object implementations into it if you feel a need to simplify the API itself and/or adapt it to a given document format. http://lxml.de/objectify.html Stefan -- https://mail.python.org/mailman/listinfo/python-list
Getting response over logging socket
I have an app that uses the logging package with a SocketHandler to send messages. Now I've been asked to change it so that it can receive a response for each log message sent. It appears there is no way to do this with logging package. Is that true? Can I not receive data over a socket used in a logging handler? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
Op 09-09-15 om 01:55 schreef Michael Torrie: > In any case, 0-based indexing in Python makes a lot of sense when you > bring in the slicing syntax. Especially if you think of slicing as > operating on the boundaries between cells as it were. Then you have never used slices with a negative step. If slicing would operate on the boundaries between cells then the reverse of lst[2:7] would be lst[7:2:-1] instead it is lst[6:1:-1] This gets you in trouble when you want to reverse through lst[0:8] which would be lst[7:-1:-1] but now the special meaning of negative indexes kicks in and you are screwed. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: issue while doing pexpect ssh
In a message of Wed, 09 Sep 2015 01:58:30 -0700, [email protected] wr ites: >Thank you for spawnu, now i got stuck with freezing issue similar to it is not >returing to the shell prompt...its on waiting...i had to press ctrl+c > >=== >child.sendline(password) >child.expect('-bash-4.1$') >child.sendline('ls') >print(child.before) >child.sendline('su - user1') >child.expect('-bash-4.1$') >child.sendline('pwd; hostname') >print(child.before) >child.close() >WARNING. You have accessed a private computer system. Any doubts we had about whether the computer policy authorities as this place are 'nuttier than 2 trees full of squirrels' are now put to rest. I just hope I am not helping you do things that is going to end up with them trying to put you in jail. Poor you. >su - user1 > >lsTotal users logged in under your name (via BoKS): 3 (2 on this host) >Total users logged in (via BoKS): 8324 (2 on this host) >-bash-4.1$ ls >-bash-4.1$ su - user1 >-bash-4.1$ Okay. Instead of waiting for that bash-4.1 prompt after you issue your su, issue whoami and wait to see if it returns user1. That way we can see if the problem is with expect waiting for the prompt which for some reason it is not seeing, or whether it is just lost, lost, lost. Also, for informational purposes try your su without the '-' just "su user1", and see if it is some part of the 'provide an environment similar to what the user would get if the user logged in directly' ability of su that is confusing things. Laura -- https://mail.python.org/mailman/listinfo/python-list
Re: issue while doing pexpect ssh
>Hey All, > >I am able to achieve this using pxssh.. thank you for help... Great to hear it. Good luck with the crazies. Laura -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On Wed, 09 Sep 2015 09:13:41 +0100, Tim Golden wrote: > On 09/09/2015 08:59, Laszlo Lebrun via Python-list wrote: >> On Tue, 08 Sep 2015 23:35:33 +0100, Mark Lawrence wrote: >> >>> On 08/09/2015 20:14, Laszlo Lebrun via Python-list wrote: Dear group, I do use Windows 7 and have a user name with diacritics. Whenever I am querying an extension with pip, it will fail since it does not pass on the user folder correctly. I thought PIP deals well with unicode, doesn't it? > >> Yes, you are right, let me append the message. >> Just after a fresh install of Python with PIP on Windows. >> Whenever I start PIP, I get: >> "Fatal error in launcher: Unable to create process using '"C:\Users >> \B├╝rgerGegenFlugl├ñrm\AppData\Local\Programs\Python\Python35-32 >> \python.exe" >> "C:\Users\B³rgerGegenFluglõrm\AppData\Local\Programs\Python >> \Python35-32\Scripts\pip.exe" '" >> >> Where the correct path is "C:\Users\BürgerGegenFluglärm\AppData..." >> >> The funny thing is that the message mentions the path twice, with >> different wrong codings. >> :-( >> >> > What version of pip are you using? Since (from the path) I guess you > have a 32-bit version of Python 3.5, I assume it's the version which was > installed with that but just check: > > pip --version > Sorry I can't even execute that one. I keep getting the weird error message. But I just downloaded it 3 days ago, so it should be the current one. > Hopefully someone here can help, but in fact pip is not part of core > Python: the ensurepip mechanism (which *is* part of core Python) > bootstraps a recent version of pip but it's maintained elsewhere. > > So you may need to raise this as a bug on the Pip tracker: > > https://github.com/pypa/pip/issues > done. Thank you. -- Stand up against TTIP and ISDS ! -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On Wed, 09 Sep 2015 00:22:31 -0700, wxjmfauth wrote: > Yes, I know how to fix all these problems. I know as well: have a user, which name is just plain ASCII. But it sucks to rebuild everything... -- Stand up against TTIP and ISDS ! -- https://mail.python.org/mailman/listinfo/python-list
Re: issue while doing pexpect ssh
On Tuesday, 8 September 2015 17:07:24 UTC+5:30, [email protected] wrote: > Some where i am missing simple logic :) > > = > child = pexpect.spawn('ssh hari@hostname') > child.logfile = sys.stdout > child.expect('hari\'s Password: ') > = > > getting error as follows: > > child.expect('hari\'s Password: ') > TypeError: must be str, not bytes > === > > Thanks... Hi Laura, Basically its the same, no difference if i keep su user1... i am getting the desired output with a single host, but if i keep for loop for multiple hosts, remaining are skipped saying as below: pexpect.TIMEOUT: Timeout exceeded. During handling of the above exception, another exception occurred: pexpect.TIMEOUT: Timeout exceeded. only 1st host is getting executed. how to control child.logout() and make for loop continue... -- https://mail.python.org/mailman/listinfo/python-list
Re: Hi am new to python
On Tue, 08 Sep 2015 17:44:26 -0500, Nassim Gannoun wrote: > Hi I'm also new to Python but would like to reply. > Like others have stated there is a built in function (sum) that can give > the sum of the elements of a list, but if what you are trying to do is > learn how to use the while command here is some code that will work. > Your question: > My question is in a while loop; how do l sum all the numbers in the > given list (list_a)? > > list_a = [8, 5, 2, 4] > sum_a = 0 # for storing the sum of list_a i = 0 # for looping through > the list_a# Use a while loop to sum all numbers in list_a# If you store > the sums into sum_a print(sum_a) # should print 19 My answer: > list_a = [8, 5, 2, 4] > > > > sum_a = 0 i = 0 while i < (len(list_a)): > sum_a += list_a[i] > i += 1 > > > print(sum_a) > This is OK a a learning excise but it is just about the worst way to achieve the result in python. It should be considered as an example of how NOT to perform the task. I do hope this is NOT a homework question set by a teacher as it would get the student into bad habits. -- It's spelled Linux, but it's pronounced `Not Windows' It's spelled Windows, but it's pronounced `Ai!' -- Shannon Hendrix -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On Wed, Sep 9, 2015 at 9:07 PM, Laszlo Lebrun via Python-list wrote: > On Wed, 09 Sep 2015 00:22:31 -0700, wxjmfauth wrote: > >> Yes, I know how to fix all these problems. > > I know as well: have a user, which name is just plain ASCII. > But it sucks to rebuild everything... Don't bother responding to jmf - he's our resident Unicode troll. His posts don't get through to me any more, except when someone responds :) Not sure where they're getting blocked; probably at the news<->list boundary. You shouldn't have to restrict your username to ASCII. It's 2015, and non-ASCII names should work everywhere. Anywhere they don't is a bug to be fixed, and I'm confident the pip folks will treat this with the respect it deserves. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
[RELEASED] Python 3.5.0rc4 is now available!
On behalf of the Python development community and the Python 3.5 release team, I'm surprised to announce the availability of Python 3.5.0rc4, also known as Python 3.5.0 Release Candidate 4. Python 3.5.0 Release Candidate 3 was only released about a day ago. However: during testing, a major regression was discovered, reported on the issue tracker as #25027: http://bugs.python.org/issue25027 Python 3.5 includes some big changes on how Python is built on Windows. One of those changes resulted in Python processes on Windows exceeding the maximum number of loadable shared libraries. As a result Windows builds of Python could no longer run major Python software stacks like Pandas and Jupyter. Fixing this required non-trivial last-minute changes to the Windows build--and those changes need testing. We therefore elected to insert an extra release candidate before the final release, to get these changes into your hands as soon as possible, so that Windows users could test these changes. As with all other Python 3.5 releases to date, this is a preview release, and its use is not recommended for production settings. However, users are encouraged to test with Python 3.5.0rc4, /especially/ Windows users who build or make use of numerous external packages. (Non-Windows users will find little difference between Python 3.5.0rc3 and Python 3.5.0rc4.) You can find Python 3.5.0rc4 here: https://www.python.org/downloads/release/python-350rc4/ Windows and Mac users: please read the important platform-specific "Notes on this release" section near the end of that page. Please kick the tires, //arry/ p.s. Special thanks from the Python 3.5 release team to Christoph Gohlke for the bug report! -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
Op 09-09-15 om 05:27 schreef Steven D'Aprano: > >> Were those polls, like the poll he once did for the condtional expression? >> There the poll indicated no specific proposal had a majority, so for each >> specific proposal one could say it didn't have popular support, but the >> majority still prefered to have a conditional expression. But at that >> time Guido used that poll as an indication there was not enough support. > In the case of conditional expression, there is *no good alternative*. Yet there were people who passionatly argued against introducing one. Even when list comprehensions were introduced where they really would be useful some people still fought it. Just to show that people fighting something is not a strong argument. > Using if...then statement is too heavyweight, and cannot be used in an > expression. Using "flag and true_value or false_value" is buggy -- it fails > if true_value is itself false. Refactoring it to a function uses eager > rather than lazy evaluation. So there was no existing alternative to a > ternary if expression that worked correctly. Yes there was. There were even two. One was packing your values into a one element list, the other was packing them in a lambda. It was ugly but it was what people came up with for lack of better. > In the case of case/switch, there is no consensus on what the statement > should do, how it should work, what purpose it has, or what syntax it > should use. Rather than "there's no alternative to a case statement", the > situation was more like "there are many good alternatives to the various > different case statements people want". Since when does Guido need a consensus? Look the developers have only limited time, and they get to choose what they consider a priority and what they don't. And if they think other things have higher priority, fine by me. But don't come with, no support/consensus with the users, because if the dev-team thinks something is a good idea, they'll implement it without much consideration for support/consensus among the users. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On 09/09/2015 14:10, Chris Angelico wrote: > Don't bother responding to jmf - he's our resident Unicode troll. His > posts don't get through to me any more, except when someone responds > :) Not sure where they're getting blocked; probably at the news<->list > boundary. They're held for mailing list moderation. If they're the usual rant I discard them. > You shouldn't have to restrict your username to ASCII. It's 2015, and > non-ASCII names should work everywhere. Anywhere they don't is a bug > to be fixed, and I'm confident the pip folks will treat this with the > respect it deserves. Definitely. I'll try to reproduce this at home (when I have access to a machine on which I can create a suitably unicode-y username). TJG -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
Am 09.09.15 um 05:23 schrieb Steven D'Aprano: And yes, the fellow Joe who completely missed the point of the blog post, and made the comment "You don’t think you’re wrong and that’s part of a much larger problem, but you’re still wrong" completely deserved to be called out on his lack of reading comprehension and smugness. This sentence is a very arrogant one, yes, but it is quoted from the article. Overall I have the feeling that the point he wants to make is a very subtle one. Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On 09.09.2015 10:23, Chris Angelico wrote: On Wed, Sep 9, 2015 at 5:59 PM, Laszlo Lebrun via Python-list wrote: Whenever I start PIP, I get: "Fatal error in launcher: Unable to create process using '"C:\Users \B├╝rgerGegenFlugl├ñrm\AppData\Local\Programs\Python\Python35-32 \python.exe" "C:\Users\B³rgerGegenFluglõrm\AppData\Local\Programs\Python \Python35-32\Scripts\pip.exe" '" Where the correct path is "C:\Users\BürgerGegenFluglärm\AppData..." The funny thing is that the message mentions the path twice, with different wrong codings. :-( I may be wrong, but isn't the error message suggesting that this is a bug in the py launcher instead of in pip? If I remember a post from a recent thread correctly, then pip.exe is just a script using the launcher. If that's true, shouldn't the recommended: python -m pip be a workaround? I might be wrong, but it's worth a try. Best, Wolfgang -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On 09/09/2015 17:16, Wolfgang Maier wrote: > On 09.09.2015 10:23, Chris Angelico wrote: >> On Wed, Sep 9, 2015 at 5:59 PM, Laszlo Lebrun via Python-list >> wrote: >>> Whenever I start PIP, I get: >>> "Fatal error in launcher: Unable to create process using '"C:\Users >>> \B├╝rgerGegenFlugl├ñrm\AppData\Local\Programs\Python\Python35-32 >>> \python.exe" >>> "C:\Users\B³rgerGegenFluglõrm\AppData\Local\Programs\Python >>> \Python35-32\Scripts\pip.exe" '" >>> >>> Where the correct path is "C:\Users\BürgerGegenFluglärm\AppData..." >>> >>> The funny thing is that the message mentions the path twice, with >>> different wrong codings. >>> :-( >> > > I may be wrong, but isn't the error message suggesting that this is a > bug in the py launcher instead of in pip? > If I remember a post from a recent thread correctly, then pip.exe is > just a script using the launcher. > If that's true, shouldn't the recommended: > > python -m pip > > be a workaround? > > I might be wrong, but it's worth a try. Actually, that's a good point. Especially given the start of the error message... TJG -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On 09/09/2015 16:04, Antoon Pardon wrote: Op 09-09-15 om 05:27 schreef Steven D'Aprano: In the case of case/switch, there is no consensus on what the statement should do, how it should work, what purpose it has, or what syntax it should use. Rather than "there's no alternative to a case statement", the situation was more like "there are many good alternatives to the various different case statements people want". Since when does Guido need a consensus? Look the developers have only limited time, and they get to choose what they consider a priority and what they don't. And if they think other things have higher priority, fine by me. But don't come with, no support/consensus with the users, because if the dev-team thinks something is a good idea, they'll implement it without much consideration for support/consensus among the users. A number of recent PEPs have been given delegated authority, so someone other than Guido makes the final decision as to whether to accept or reject it. I can only suggest you don't follow some of the intense wars of words that go on on python-dev, or even python-ideas, as the part about this dev-team simply overriding users is nonsense. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On Thu, 10 Sep 2015 02:09 am, Christian Gollwitzer wrote: > Am 09.09.15 um 05:23 schrieb Steven D'Aprano: >> And yes, the fellow Joe who completely missed the point of the blog post, >> and made the comment "You don’t think you’re wrong and that’s part of a >> much larger problem, but you’re still wrong" completely deserved to be >> called out on his lack of reading comprehension and smugness. > > This sentence is a very arrogant one, yes, but it is quoted from the > article. Overall I have the feeling that the point he wants to make is a > very subtle one. Subtle enough that his quoting the author's words back at him escaped me, but I suspect not subtle enough to escape the author's notice. Hence the reply "Thanks for leaving your comment. I’m sure it’s made you feel very clever." I think my favourite is the guy who claims that the reason natural languages all count from 1 is because the Romans failed to invent zero. (What about languages that didn't derive from Latin, say, Chinese?) And that now that we have zero, counting from it should be more natural. So if you give somebody two apples, but no banana, and ask them to count their apples, they would count "Zero, one... therefore I have two apples". And if you then ask them to count their bananas, they would do what? +++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++ -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On Thu, Sep 10, 2015 at 3:22 AM, Steven D'Aprano wrote: > I think my favourite is the guy who claims that the reason natural languages > all count from 1 is because the Romans failed to invent zero. (What about > languages that didn't derive from Latin, say, Chinese?) And that now that > we have zero, counting from it should be more natural. So if you give > somebody two apples, but no banana, and ask them to count their apples, > they would count "Zero, one... therefore I have two apples". And if you > then ask them to count their bananas, they would do what? They would respond that there is a subtle difference between "Please count your bananas" and "Please, Count... you're bananas". ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3.3 couldnt find its libraries.
On Wed, 9 Sep 2015 07:37 pm, Φώντας Λαδοπρακόπουλος wrote: [...] > [root@superhost ~]# /opt/rh/python33/root/usr/bin/python -V > /opt/rh/python33/root/usr/bin/python: error while loading shared > libraries: libpython3.3m.so.1.0: cannot open shared object file: No such > file or directory Again? Nikos, this looks like exactly the same error you got back in April, in the thread with subject line "Question Installing latest Python". The date was around 29 Apr 2015, possibly a couple of days either side. I suggest you go back and read the replies to that. If this is the same problem, then I think these were the steps you followed last time. Try running this as a regular user: python3 -c "import sys; print(sys.executable)" Does it work? If not, run this as the root user: ldconfig That will tell your system to cache any shared libraries it knows about. yum is supposed to do that for you, but perhaps it didn't. Now try running the python3 test above. Does it work? Then the problem is solved and you can stop reading. If you get the same error, then run this as root: find /opt -name libpython3.3m.so.1.0 If it returns a single result, that's good. If it returns no results, try this instead: find / -name libpython3.3m.so.1.0 2> /dev/null It may take a while: it's going to search your entire hard drive. Hopefully that will return a single result: let's say it returns /this/that/libpython3.3m.so.1.0 then you need to edit /etc/ld.so.conf and add this line to the end: /this/that Save your changes, run ldconfig again, and hopefully python3 will now work. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On Wed, 9 Sep 2015 11:09 am, Mario Figueiredo wrote: > You know, it is a pointless exercise to try and downplay programming > languages (any programming language) that has proven its worth by being > generally adopted by the programming community. Adoption is the sign of > a respected and well designed language. Counter-examples: PHP and C. Adoption of programming languages is driven by many things, technical excellence and careful design are not even in the top 10. Most of them are social in nature, particularly "what is everyone else using?". Network effects dominate: you could design the perfect language, but if nobody else uses it, nobody will use it. Sometimes a language will actually gain a kind of technical excellence despite some really shitty design decisions -- but usually at great cost elsewhere. C is a good example of that. Due to lousy decisions made by the designers of C, it is a language really well suited for writing fast, incorrect code. Since programmers benefit from writing fast code, but rarely suffer from writing incorrect code (it's mostly users who suffer the consequences of security holes), we have ended up in the situation we live in now, where compilers compete to write faster and faster code that has less and less relation to what the programmer intended. (I wanted to link to the "Everything Is Broken" essay on The Medium, but the page appears to be gone. This makes me sad. BTW, what's the point of Google's cache when it just redirects to the original, missing, page?) In fairness to the C creators, I'm sure that nobody back in the early seventies imagined that malware and security vulnerabilities would be as widespread as they have become. But still, the fundamental decisions made by C are lousy. Assignment is an expression? Lack of first-class arrays? The C pre-processor? They're pretty awful, but *nothing* in the entire history of computing, not even Intercal and the COMEFROM command, comes even close to the evil that is C "undefined behaviour". I believe that the computing industry may never recover from the harm done to it by the widespread use of C. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
In a message of Thu, 10 Sep 2015 03:55:54 +1000, "Steven D'Aprano" writes: >(I wanted to link to the "Everything Is Broken" essay on The Medium, but the >page appears to be gone. This makes me sad. BTW, what's the point of >Google's cache when it just redirects to the original, missing, page?) Working for me: https://medium.com/message/everything-is-broken-81e5f33a24e1 Laura -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On 9/9/2015 10:55 AM, Steven D'Aprano wrote: (I wanted to link to the "Everything Is Broken" essay on The Medium, but the page appears to be gone. Is this it? http://www.sott.net/article/280956-Everything-is-broken-on-the-Internet -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On 09.09.2015 19:55, Steven D'Aprano wrote: On Wed, 9 Sep 2015 11:09 am, Mario Figueiredo wrote: You know, it is a pointless exercise to try and downplay programming languages (any programming language) that has proven its worth by being generally adopted by the programming community. Adoption is the sign of a respected and well designed language. Counter-examples: PHP and C. Adoption of programming languages is driven by many things, technical excellence and careful design are not even in the top 10. Most of them are social in nature, particularly "what is everyone else using?". Network effects dominate: you could design the perfect language, but if nobody else uses it, nobody will use it. Just to understand it the way you want it to be understood: what do you mean by "technical excellence"? Sometimes a language will actually gain a kind of technical excellence despite some really shitty design decisions -- but usually at great cost elsewhere. C is a good example of that. Due to lousy decisions made by the designers of C, it is a language really well suited for writing fast, incorrect code. Since programmers benefit from writing fast code, but rarely suffer from writing incorrect code (it's mostly users who suffer the consequences of security holes), we have ended up in the situation we live in now, where compilers compete to write faster and faster code that has less and less relation to what the programmer intended. (I wanted to link to the "Everything Is Broken" essay on The Medium, but the page appears to be gone. This makes me sad. BTW, what's the point of Google's cache when it just redirects to the original, missing, page?) Do you mean https://medium.com/message/everything-is-broken-81e5f33a24e1 ? In fairness to the C creators, I'm sure that nobody back in the early seventies imagined that malware and security vulnerabilities would be as widespread as they have become. But still, the fundamental decisions made by C are lousy. Assignment is an expression? Lack of first-class arrays? The C pre-processor? They're pretty awful, but *nothing* in the entire history of computing, not even Intercal and the COMEFROM command, comes even close to the evil that is C "undefined behaviour". I believe that the computing industry may never recover from the harm done to it by the widespread use of C. It'll take some time. -- https://mail.python.org/mailman/listinfo/python-list
Lesson 39 of Learning Python the Hard Way hangs
Hi all I am new to python but not programming (Although rusty) and am using Learning Python The Hard Way. I really like it. System: --- Debian 8 (jessie) KDE Desktop Python 2.7 (It's going to be a while before 2,7 goes away. There is just too much code out there. Ninja-IDE IDE - I like this a lot. I can't seem to find out how to put breaks into the code though. The debugger plugin is installed. -- For some reason lesson 39 is hanging and I can't find the cause. A print statement inserted into the get_slot function just after bucket shows that get_bucket is returning an []. It' not surprising that enumerate() doesn't like this very much. I just can't find the cause. The error message is as follows: --- Running: /root/mystuff/mystuff/ex39_test.py (Wed Sep 9 09:57:51 2015) Traceback (most recent call last): File "/root/mystuff/mystuff/ex39_test.py", line 6, in hashmap.set(states, 'Oregon', 'OR') File "/root/mystuff/mystuff/hashmap.py", line 50, in set i, k, v = get_slot(aMap, key) TypeError: 'NoneType' object is not iterable Execution Successful! NOTE: Line 50 is the - i, k, v = get_slot(aMap, key)- of def set. The calling code is: # -*- coding: utf-8 -*- import hashmap # creat a mapping of stat to abbreviation states = hashmap.new() hashmap.set(states, 'Oregon', 'OR') The hashmap code is as follows: def new(num_buckets=256): """Initializes a Map with the given number of buckets.""" aMap = [] for i in range(0, num_buckets): aMap.append([]) return aMap def hash_key(aMap, key): """Given a key this will create a number and then convert it to an index for the aMap's buckets.""" return hash(key) % len(aMap) def get_bucket(aMap, key): """Given a key, find the bucket where it would go.""" bucket_id = hash_key(aMap, key) return aMap[bucket_id] def get_slot(aMap, key, default=None): """ Returns the index, key, and value of a slot found in a bucket. Returns -1, key, and default (None if not set) when not found. """ bucket = get_bucket(aMap, key) for i, kv in enumerate(bucket): k, v = kv if key == k: return i, k, v return -1, key, default def get(aMap, key, default=None): """Gets the value in a bucket for the given key, or the default.""" i, k, v = get_slot(aMap, key, default=default) return v def set(aMap, key, value): """Sets the key to the value, replacing any existing value.""" bucket = get_bucket(aMap, key) i, k, v = get_slot(aMap, key) if i >= 0: # the key exists, replace it bucket[i] = (key, value) else: # the key does not, append to create it bucket.append((key, value)) def delete(aMap, key): """Deletes the given key from the Map.""" bucket = get_bucket(aMap, key) for i in xrange(len(bucket)): k, v = bucket[i] if key == k: del bucket[i] break def list(aMap): """Prints out what's in the Map.""" for bucket in aMap: if bucket: for k, v in bucket: print k, v Very frustrating and probably a stupid error. Any help will be sincerely appreciated. Gary R. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On Wed, Sep 9, 2015, at 13:55, Steven D'Aprano wrote: > In fairness to the C creators, I'm sure that nobody back in the early > seventies imagined that malware and security vulnerabilities would be as > widespread as they have become. But still, the fundamental decisions made > by C are lousy. Assignment is an expression? Whoa, hold on. The problem with C assignment isn't that it's an expression, it's that it's spelled "=" and can be used in contexts where one would normally do an equality comparison. In some languages (Lisp/Scheme/etc come to mind), *everything* is an expression. But assignment is spelled with, generally, some variant of "set" [setq, set!, etc]. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
> On Sep 9, 2015, at 1:22 PM, Steven D'Aprano wrote: > > [byte] > > I think my favourite is the guy who claims that the reason natural languages > all count from 1 is because the Romans failed to invent zero. (What about > languages that didn't derive from Latin, say, Chinese?) Right. Note that the Arabs, who DID invent zero, still count from one. Bill -- https://mail.python.org/mailman/listinfo/python-list
Re: RPI.GPIO Help
Hello.
As per the suggestion of two of you I went to the Raspberry Pi
newsgroup. Dennis is also there and has been posting in response to my
problems. Between there and the Raspberry Foundation website I discovered
that my wiring did not match my code and changed all PUD_DOWN to PUD_UP
and all GPIO.RISING to GPIO.FALLING because I was wired to the ground pin.
Someone suggested code very close to what hakugin suggested.
Right now I have response buttons that work, but the colour of the LED
strip is not correct. It adds colours instead of changing to a new one. I
hit red, it pulses red, I hit blue, it pulses red and blue, making purple.
It appears now my problem is more about Python usage than anything else,
so I am asking for help here as well as having already asked elsewhere.
Tried using a go to black command (led.set_color(name="black")) and a
turn off command (led.turn_off()) before the pulse command to reset the
colour and these did not work. To see what would happen I removed the
"while colour == 1:" (or == 2: or ==3:) line and it acted as expected.
The LED pulsed once. However, it would pulse the correct colour, it would
not add colours together.
So the while loop seems to be the cause of my problem, but it is needed
to keep the pulse repeating as far I can know. Maybe Python has another
way to repeat the function.
Here is the code I was working from:
import atexit
import time
from blinkstick import blinkstick
import RPi.GPIO as GPIO
led = blinkstick.find_first()
colour = 0
time_red = 0
time_yellow = 0
time_blue = 0
timestamp = time.strftime("%H:%M:%S")
GPIO.setmode(GPIO.BCM)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def red_button(channel):
led.set_color(name="black")
colour = 1
while colour == 1:
led.pulse(red=255, green=0, blue=0, repeats=1, duration=3000,
steps=50)
def yellow_button(channel):
led.set_color(name="black")
colour = 2
while colour == 2:
led.pulse(red=255, green=255, blue=0, repeats=1, duration=3000,
steps=50)
def blue_button(channel):
led.set_color(name="black")
colour = 3
while colour == 3:
led.pulse(red=0, green=0, blue=255, repeats=1, duration=2000,
steps=50)
GPIO.add_event_detect(22, GPIO.FALLING, callback=red_button,
bouncetime=200)
GPIO.add_event_detect(23, GPIO.FALLING, callback=yellow_button,
bouncetime=200)
GPIO.add_event_detect(24, GPIO.FALLING, callback=blue_button,
bouncetime=200)
while True:
if colour == 1:
time_red += 1
elif colour == 2:
time_yellow += 1
elif colour == 3:
time_blue += 1
time.sleep(0.1)
def exit_handler():
print "\033[0;41;37mRed Team:\033[0m ", time_red
print "\033[0;43;30mYellow Time:\033[0m ", time_yellow
print "\033[0;44;37mBlue Time:\033[0m ", time_blue
flog = open("flag1.log", "a")
flog.write(timestamp + "\n" + "Red Team: " + str(time_red) + "\n" +
"Yellow Team: " + str(time_yellow) + "\n" + "Blue Team: " + str
(time_blue) + "\n")
flog.close()
GPIO.cleanup()
atexit.register(exit_handler)
Any advice about the while loop for the colour pulsing is appreciated.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On Thu, Sep 10, 2015 at 4:26 AM, Sven R. Kunze wrote: >> Adoption of programming languages is driven by many things, technical >> excellence and careful design are not even in the top 10. Most of them are >> social in nature, particularly "what is everyone else using?". Network >> effects dominate: you could design the perfect language, but if nobody >> else >> uses it, nobody will use it. > > Just to understand it the way you want it to be understood: what do you mean > by "technical excellence"? Suppose it's possible, somehow, to design the perfect language. (It isn't, because the best language for a job depends on the job, but suppose it for the nonce.) It is simultaneously more readable than Python, more ugly than Perl, more functional than Haskell, and compiles to lower level code than C does. The compiler's/interpreter's internals are a bug-free demonstration of utter code beauty, and you no longer have reason to use any other programming language, because this one is the ultimate. But nobody uses it except you. Technical excellence it has a'plenty, but is it going to be on the job postings? No. Is it going to be on people's resumes? No. When a programmer pitches a proposal at his manager, will he mention your language, which he's never heard of? No. When someone asks on Stack Overflow "How do I...", will the answers recommend the use of your language? No. It isn't going to be used, no matter how good it is, if nobody knows about it. And if it isn't used, nobody will get to know it. Until you start getting some usage, you won't get much usage. That's what drives programming language adoption: existing usage. It's self-perpetuating and proves little. To get started, you need some other sort of kick. Maybe a high-profile company uses your language. Maybe a hardware manufacturer mandates its use. Maybe your development team has so many famous names that the world has been watching with interest. But whatever it is, it has to be something big or you won't get over that initial usage hump. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
In a message of Thu, 10 Sep 2015 05:00:22 +1000, Chris Angelico writes: >To get started, you need some other sort of kick. Having Brian Kernighan write a really nice book about you, helps a lot. Laura -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On Thu, Sep 10, 2015 at 5:14 AM, Laura Creighton wrote: > In a message of Thu, 10 Sep 2015 05:00:22 +1000, Chris Angelico writes: >>To get started, you need some other sort of kick. > > Having Brian Kernighan write a really nice book about you, helps a lot. It kinda does. And of course, it also helps to have a time machine, so you can launch your language when there are less languages around. Today, you compete for attention with myriad languages that simply didn't exist when C was introduced to an unsuspecting world. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On 09.09.2015 21:00, Chris Angelico wrote: Suppose it's possible, somehow, to design the perfect language. (It isn't, because the best language for a job depends on the job, but suppose it for the nonce.) It is simultaneously more readable than Python, more ugly than Perl, more functional than Haskell, and compiles to lower level code than C does. The compiler's/interpreter's internals are a bug-free demonstration of utter code beauty, and you no longer have reason to use any other programming language, because this one is the ultimate. That sounds boring, right? ;) Best, Sven -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On 09/09/2015 18:59, William Ray Wing wrote: On Sep 9, 2015, at 1:22 PM, Steven D'Aprano wrote: [byte] I think my favourite is the guy who claims that the reason natural languages all count from 1 is because the Romans failed to invent zero. (What about languages that didn't derive from Latin, say, Chinese?) Right. Note that the Arabs, who DID invent zero, still count from one. Bill Would you please provide a citation to support your claim as this http://www.livescience.com/27853-who-invented-zero.html disagrees. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On 2015-09-09 18:59, William Ray Wing wrote: On Sep 9, 2015, at 1:22 PM, Steven D'Aprano wrote: [byte] I think my favourite is the guy who claims that the reason natural languages all count from 1 is because the Romans failed to invent zero. (What about languages that didn't derive from Latin, say, Chinese?) Right. Note that the Arabs, who DID invent zero, still count from one. No, they didn't invent zero. Bill -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On Thu, Sep 10, 2015 at 5:20 AM, Mark Lawrence wrote: > On 09/09/2015 18:59, William Ray Wing wrote: >> Right. Note that the Arabs, who DID invent zero, still count from one. > > Would you please provide a citation to support your claim as this > http://www.livescience.com/27853-who-invented-zero.html disagrees. There will be no such citation, because it's well known that zero was invented by the jungle natives of Papua New French Guiana. http://www.jumbojoke.com/high_tech_natives.html ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: RPI.GPIO Help
On 2015-09-09 20:03, John McKenzie wrote:
Hello.
As per the suggestion of two of you I went to the Raspberry Pi
newsgroup. Dennis is also there and has been posting in response to my
problems. Between there and the Raspberry Foundation website I discovered
that my wiring did not match my code and changed all PUD_DOWN to PUD_UP
and all GPIO.RISING to GPIO.FALLING because I was wired to the ground pin.
Someone suggested code very close to what hakugin suggested.
Right now I have response buttons that work, but the colour of the LED
strip is not correct. It adds colours instead of changing to a new one. I
hit red, it pulses red, I hit blue, it pulses red and blue, making purple.
It appears now my problem is more about Python usage than anything else,
so I am asking for help here as well as having already asked elsewhere.
Tried using a go to black command (led.set_color(name="black")) and a
turn off command (led.turn_off()) before the pulse command to reset the
colour and these did not work. To see what would happen I removed the
"while colour == 1:" (or == 2: or ==3:) line and it acted as expected.
The LED pulsed once. However, it would pulse the correct colour, it would
not add colours together.
So the while loop seems to be the cause of my problem, but it is needed
to keep the pulse repeating as far I can know. Maybe Python has another
way to repeat the function.
Here is the code I was working from:
import atexit
import time
from blinkstick import blinkstick
import RPi.GPIO as GPIO
led = blinkstick.find_first()
colour = 0
time_red = 0
time_yellow = 0
time_blue = 0
timestamp = time.strftime("%H:%M:%S")
GPIO.setmode(GPIO.BCM)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def red_button(channel):
led.set_color(name="black")
colour = 1
while colour == 1:
led.pulse(red=255, green=0, blue=0, repeats=1, duration=3000,
steps=50)
def yellow_button(channel):
led.set_color(name="black")
colour = 2
while colour == 2:
led.pulse(red=255, green=255, blue=0, repeats=1, duration=3000,
steps=50)
def blue_button(channel):
led.set_color(name="black")
colour = 3
while colour == 3:
led.pulse(red=0, green=0, blue=255, repeats=1, duration=2000,
steps=50)
GPIO.add_event_detect(22, GPIO.FALLING, callback=red_button,
bouncetime=200)
GPIO.add_event_detect(23, GPIO.FALLING, callback=yellow_button,
bouncetime=200)
GPIO.add_event_detect(24, GPIO.FALLING, callback=blue_button,
bouncetime=200)
while True:
if colour == 1:
time_red += 1
elif colour == 2:
time_yellow += 1
elif colour == 3:
time_blue += 1
time.sleep(0.1)
def exit_handler():
print "\033[0;41;37mRed Team:\033[0m ", time_red
print "\033[0;43;30mYellow Time:\033[0m ", time_yellow
print "\033[0;44;37mBlue Time:\033[0m ", time_blue
flog = open("flag1.log", "a")
flog.write(timestamp + "\n" + "Red Team: " + str(time_red) + "\n" +
"Yellow Team: " + str(time_yellow) + "\n" + "Blue Team: " + str
(time_blue) + "\n")
flog.close()
GPIO.cleanup()
atexit.register(exit_handler)
Any advice about the while loop for the colour pulsing is appreciated.
It's the same problem as before, and it has the same answer.
In red_button, yellow_button and blue_button, 'colour' is a local
variable. It's set to a value and that value is never changed in the
loop, so it loops forever.
You should declare 'colour' to be global in all 3 functions, e.g.:
def red_button(channel):
global colour
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On 09/09/2015 20:14, Laura Creighton wrote: In a message of Thu, 10 Sep 2015 05:00:22 +1000, Chris Angelico writes: To get started, you need some other sort of kick. Having Brian Kernighan write a really nice book about you, helps a lot. Laura Who? Did he play left wing or right wing for City? Or was it United? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On 09-09-2015 18:55, Steven D'Aprano wrote: > On Wed, 9 Sep 2015 11:09 am, Mario Figueiredo wrote: > >> You know, it is a pointless exercise to try and downplay programming >> languages (any programming language) that has proven its worth by being >> generally adopted by the programming community. Adoption is the sign of >> a respected and well designed language. > > Counter-examples: PHP and C. > > Adoption of programming languages is driven by many things, technical > excellence and careful design are not even in the top 10. Most of them are > social in nature, particularly "what is everyone else using?". Network > effects dominate: you could design the perfect language, but if nobody else > uses it, nobody will use it. You paint a dim picture of the computer science ecosystem. You almost make it look like we are a bunch of fashionists. There is some truth to what you are saying, but not to the level you are implying. "Technical excellence not being on the top 10" is just a blanket statement that does not address the constant search for better programming languages. The fact is that you, I and a large representative number of software engineers are always on the constant lookout for better designed languages. And it's people like us that eventually ensure the success of a programming language based on its merits. It's the software engineering "society" that eventually promotes a programming language out of obscurity and into popular use. And this can only happen if that language holds enough merits. We may have been experiencing a rise in programming languages protected by commercial interests, but so far they still obey this simple truth. That speech that languages are popularity contests is just a superficial view of the whole of the industry and frankly very much untrue. > Sometimes a language will actually gain a kind of technical excellence > despite some really shitty design decisions -- but usually at great cost > elsewhere. C is a good example of that. Due to lousy decisions made by the > designers of C, it is a language really well suited for writing fast, > incorrect code. Right. There we go. Another, C is a badly designed language... If I had a penny for every time I heard this, I could then wish for a penny for every other program or computer language that was designed in C. I would be twice as rich. Almost all of the modern programming edifice sits on top of C on one way or another. Our operating systems, many of our most mission critical system, even many of our high level programming languages, including the one represented on these forums. But somehow, there is always someone trying to sell that C is a lousy designed programming language. At this point in history, I couldn't blame C anymore. If it is such a lousy job, then the real problem must be with the people that kept on truckin' it around. That includes the whole of the computer science industry. And that just doesn't make sense. Your programming language based on lousy decisions, proved instead that those those lousy decisions around lack of security are necessary when you need to create a systems programming language that can eventually carry on its shoulders the weight of an entire industry. Maybe Rust will finally be able to prove that you can do better. That it is actually possible to create a close-to-the-metal programming language with security in mind and as performant as C. But if it does succeed (and I'd like for it to succeed, make no mistake), it took us over 40 years to actually come up with something. > In fairness to the C creators, I'm sure that nobody back in the early > seventies imagined that malware and security vulnerabilities would be as > widespread as they have become. Of course they did. The Design of C states this on several occasions, while The C Programming Language is full of mentions to the security concerns in some of the programming language semantics. Meanwhile the patterns and best practices for secure C code are known for decades, well before the widespread use of computers and the internet itself. > I believe that the computing industry may never recover from the harm done > to it by the widespread use of C. Yes. It's been a terrible 4 decades of technological innovation. -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On 09/09/2015 08:59, Laszlo Lebrun via Python-list wrote: On Tue, 08 Sep 2015 23:35:33 +0100, Mark Lawrence wrote: On 08/09/2015 20:14, Laszlo Lebrun via Python-list wrote: Dear group, I do use Windows 7 and have a user name with diacritics. Whenever I am querying an extension with pip, it will fail since it does not pass on the user folder correctly. I thought PIP deals well with unicode, doesn't it? Has anyone a clue how to fix it? Thank you Yes, you are right, let me append the message. Just after a fresh install of Python with PIP on Windows. Whenever I start PIP, I get: "Fatal error in launcher: Unable to create process using '"C:\Users \B├╝rgerGegenFlugl├ñrm\AppData\Local\Programs\Python\Python35-32 \python.exe" "C:\Users\B³rgerGegenFluglõrm\AppData\Local\Programs\Python \Python35-32\Scripts\pip.exe" '" Where the correct path is "C:\Users\BürgerGegenFluglärm\AppData..." Well on my Win8.1 machine I created a local user with the name you give and did a fresh install of the very latest Python 3.5rc. I installed from the 32-bit web installer and the only variation from the defaults was to add Python to the PATH (the last checkbox on the first page of the wizard). It all installed without issue and I was able to do "pip --version" from a command prompt to see that it had installed pip 7.1.something. Now this is on my standard dev machine, ie not a virgin VM, and it's 8.1 rather than Win7, but it's not clear why either of those would make a difference. The standard codepage for console processes appears to be 850. Let's see if the pip guys respond to your bug request TJG -- https://mail.python.org/mailman/listinfo/python-list
Re: Python handles globals badly.
On 09/09/2015 20:57, Mario Figueiredo wrote: On 09-09-2015 18:55, Steven D'Aprano wrote: On Wed, 9 Sep 2015 11:09 am, Mario Figueiredo wrote: You know, it is a pointless exercise to try and downplay programming languages (any programming language) that has proven its worth by being generally adopted by the programming community. Adoption is the sign of a respected and well designed language. Counter-examples: PHP and C. Adoption of programming languages is driven by many things, technical excellence and careful design are not even in the top 10. Most of them are social in nature, particularly "what is everyone else using?". Network effects dominate: you could design the perfect language, but if nobody else uses it, nobody will use it. You paint a dim picture of the computer science ecosystem. You almost make it look like we are a bunch of fashionists. There is some truth to what you are saying, but not to the level you are implying. "Technical excellence not being on the top 10" is just a blanket statement that does not address the constant search for better programming languages. If the designers of languages spent more time considering business benefits rather than better languages, then I believe we'd end up with better languages. However that depends on your (plural) definition of "better". -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On 09.09.2015 21:59, Tim Golden wrote: Well on my Win8.1 machine I created a local user with the name you give and did a fresh install of the very latest Python 3.5rc. I installed from the 32-bit web installer and the only variation from the defaults was to add Python to the PATH (the last checkbox on the first page of the wizard). It all installed without issue and I was able to do "pip --version" from a command prompt to see that it had installed pip 7.1.something. Now this is on my standard dev machine, ie not a virgin VM, and it's 8.1 rather than Win7, but it's not clear why either of those would make a difference. The standard codepage for console processes appears to be 850. It's been resolved a minute ago. See https://github.com/pypa/pip/issues/3087#issuecomment-139034217 for an explanation of why the latest rc does not have the bug. -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On Wed, Sep 9, 2015, at 15:59, Tim Golden wrote: > On 09/09/2015 08:59, Laszlo Lebrun via Python-list wrote: > > Yes, you are right, let me append the message. > > Just after a fresh install of Python with PIP on Windows. > > Whenever I start PIP, I get: > > "Fatal error in launcher: Unable to create process using '"C:\Users > > \B├╝rgerGegenFlugl├ñrm\AppData\Local\Programs\Python\Python35-32 > > \python.exe" "C:\Users\B³rgerGegenFluglõrm\AppData\Local\Programs\Python > > \Python35-32\Scripts\pip.exe" '" > > > > Where the correct path is "C:\Users\BürgerGegenFluglärm\AppData..." > > > Well on my Win8.1 machine I created a local user with the name you give > and did a fresh install of the very latest Python 3.5rc. I installed > from the 32-bit web installer and the only variation from the defaults > was to add Python to the PATH (the last checkbox on the first page of > the wizard). Did you install Python _under_ the user directory? If the programs it's trying to launch are in C:\Python35 instead of C:\Users\BürgerGegenFluglärm the bug won't show up. I've never actually seen an "AppData\Local\Programs\Python" directory. Is this an ActiveState thing? Is there an "Install just for me" option in the installer that will choose a different default install location? > It all installed without issue and I was able to do "pip --version" from > a command prompt to see that it had installed pip 7.1.something. > > Now this is on my standard dev machine, ie not a virgin VM, and it's 8.1 > rather than Win7, but it's not clear why either of those would make a > difference. > > The standard codepage for console processes appears to be 850. The strings shown above are, respectively, the name as UTF-8 reinterpreted as 850, and the name as 1252 reinterpreted as 850 (Incidentally, the latter will appear as "BⁿrgerGegenFluglΣrm" for US users if it is reinterpreted as 437 instead). It's possible that one or both may be caused partially by issues with how the error message was printed. -- https://mail.python.org/mailman/listinfo/python-list
Re: PIP does not appear to handle diacritics correctly.
On Wed, 09 Sep 2015 17:21:59 +0100, Tim Golden wrote: > On 09/09/2015 17:16, Wolfgang Maier wrote: >> On 09.09.2015 10:23, Chris Angelico wrote: >>> On Wed, Sep 9, 2015 at 5:59 PM, Laszlo Lebrun via Python-list >>> wrote: Whenever I start PIP, I get: "Fatal error in launcher: Unable to create process using '"C:\Users \B├╝rgerGegenFlugl├ñrm\AppData\Local\Programs\Python\Python35-32 \python.exe" "C:\Users\B³rgerGegenFluglõrm\AppData\Local\Programs\Python \Python35-32\Scripts\pip.exe" '" Where the correct path is "C:\Users\BürgerGegenFluglärm\AppData..." The funny thing is that the message mentions the path twice, with different wrong codings. :-( >>> >>> >> I may be wrong, but isn't the error message suggesting that this is a >> bug in the py launcher instead of in pip? >> If I remember a post from a recent thread correctly, then pip.exe is >> just a script using the launcher. >> If that's true, shouldn't the recommended: >> >> python -m pip >> >> be a workaround? >> >> I might be wrong, but it's worth a try. > > Actually, that's a good point. Especially given the start of the error > message... > > TJG python -m pip works well. That's a help, I will be able to get the libraries I need. Thank you. -- Stand up against TTIP and ISDS ! -- https://mail.python.org/mailman/listinfo/python-list
Re: Lesson 39 of Learning Python the Hard Way hangs
In Gary Roach writes: > Traceback (most recent call last): >File "/root/mystuff/mystuff/ex39_test.py", line 6, in > hashmap.set(states, 'Oregon', 'OR') >File "/root/mystuff/mystuff/hashmap.py", line 50, in set > i, k, v = get_slot(aMap, key) > TypeError: 'NoneType' object is not iterable > Execution Successful! Where does the message "Execution Successful!" come from? It seems like you have other code that you haven't shown us. In any case, I saved your code and ran it, and did not get an error. -- John Gordon A is for Amy, who fell down the stairs [email protected] B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list
Potential Solution for AssertionError: invalid dtype determination in get_concat_dtype when concatenating operation on list of Dataframes?
I have a list of Pandas Dataframes that I am attempting to combine using the
concatenation function.
dataframe_lists = [df1, df2, df3]
result = pd.concat(dataframe_lists, keys = ['one', 'two','three'],
ignore_index=True)
The full traceback that I receive when I execute this function is:
---
AssertionErrorTraceback (most recent call last)
in ()
> 1 result = pd.concat(dataframe_lists, keys = ['one', 'two','three'],
ignore_index=True)
2 check(dataframe_lists)
C:\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\pandas\tools\merge.py
in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names,
verify_integrity, copy)
753verify_integrity=verify_integrity,
754copy=copy)
--> 755 return op.get_result()
756
757
C:\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\pandas\tools\merge.py
in get_result(self)
924
925 new_data = concatenate_block_managers(
--> 926 mgrs_indexers, self.new_axes, concat_axis=self.axis,
copy=self.copy)
927 if not self.copy:
928 new_data._consolidate_inplace()
C:\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\pandas\core\internals.py
in concatenate_block_managers(mgrs_indexers, axes, concat_axis, copy)
4061 copy=copy),
4062 placement=placement)
-> 4063 for placement, join_units in concat_plan]
4064
4065 return BlockManager(blocks, axes)
C:\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\pandas\core\internals.py
in (.0)
4061 copy=copy),
4062 placement=placement)
-> 4063 for placement, join_units in concat_plan]
4064
4065 return BlockManager(blocks, axes)
C:\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\pandas\core\internals.py
in concatenate_join_units(join_units, concat_axis, copy)
4150 raise AssertionError("Concatenating join units along axis0")
4151
-> 4152 empty_dtype, upcasted_na = get_empty_dtype_and_na(join_units)
4153
4154 to_concat = [ju.get_reindexed_values(empty_dtype=empty_dtype,
C:\WinPython-64bit-3.4.3.5\python-3.4.3.amd64\lib\site-packages\pandas\core\internals.py
in get_empty_dtype_and_na(join_units)
4139 return np.dtype('m8[ns]'), tslib.iNaT
4140 else: # pragma
-> 4141 raise AssertionError("invalid dtype determination in
get_concat_dtype")
4142
4143
AssertionError: invalid dtype determination in get_concat_dtype
I believe that the error lies in the fact that one of the data frames is empty.
As a temporary workaround this rather perplexing error. I used the simple
function check to verify and return just the headers of the empty dataframe:
def check(list_of_df):
headers = []
for df in dataframe_lists:
if df.empty is not True:
continue
else:
headers.append(df.columns)
return headers
I am wondering if it is possible to use this function to, if in the case of an
empty dataframe, return just that empty dataframe's headers and append it to
the concatenated dataframe. The output would be a single row for the headers
(and, in the case of a repeating column name, just a single instance of the
header (as in the case of the concatenation function). I have two sample data
sources, one and two non-empty data sets.
df1: https://gist.github.com/ahlusar1989/42708e6a3ca0aed9b79b
df2 :https://gist.github.com/ahlusar1989/26eb4ce1578e0844eb82
Here is an empty dataframe.
df3 (empty dataframe): https://gist.github.com/ahlusar1989/0721bd8b71416b54eccd
I would like to have the resulting concatenate have the column headers (with
their values) that reflects df1 and df2...
'AT','AccountNum', 'AcctType', 'Amount', 'City', 'Comment',
'Country','DuplicateAddressFlag', 'FromAccount', 'FromAccountNum',
'FromAccountT','PN', 'PriorCity', 'PriorCountry', 'PriorState',
'PriorStreetAddress','PriorStreetAddress2', 'PriorZip', 'RTID', 'State',
'Street1','Street2', 'Timestamp', 'ToAccount', 'ToAccountNum', 'ToAccountT',
'TransferAmount', 'TransferMade', 'TransferTimestamp', 'Ttype', 'WA','WC', 'Zip'
as follows:
'A', 'AT','AccountNum', 'AcctType', 'Amount', 'B', 'C', 'City', 'Comment',
'Country', 'D', 'DuplicateAddressFlag', 'E', 'F' 'FromAccount',
'FromAccountNum', 'FromAccountT', 'G', 'PN', 'PriorCity', 'PriorCountry',
'PriorState', 'PriorStreetAddress','PriorStreetAddress2', 'PriorZip', 'RTID',
'State', 'Street1','Street2', 'Timestamp', 'ToAccount', 'ToAccountNum',
'ToAccountT', 'TransferAmount', 'TransferMade', 'TransferTimestamp', 'Ttype',
'WA','WC', 'Zip'
I welcome any feedback on how to best do this. Thank
Re: Lesson 39 of Learning Python the Hard Way hangs
On Wed, 09 Sep 2015 20:45:57 +, John Gordon wrote: > In any case, I saved your code and ran it, and did not get an error. +1 I think "Execution Succesful!" might be coming from his IDE? -- Denis McMahon, [email protected] -- https://mail.python.org/mailman/listinfo/python-list
Re: Hi am new to python
On Tue, 08 Sep 2015 17:44:26 -0500, Nassim Gannoun wrote: > My question is in a while loop; how do l sum all the numbers in the > given list (list_a)? You don't normally use a while loop or a counter to iterate over a list. Such a question should only be used as a precursor to discussing better methods of achieving the required result. While loop: > sum_a = 0 > i = 0 > while i < (len(list_a)): > sum_a += list_a[i] > i += 1 > print(sum_a) Better, use a for loop: s = 0 for i in list_a: s += i print (s) Even better, use sum(): s = sum(list_a) print (s) And if you only want to display the answer: print (sum(list_a)) -- Denis McMahon, [email protected] -- https://mail.python.org/mailman/listinfo/python-list
Re: Hi am new to python
On 9/9/2015 3:35 PM, Denis McMahon wrote: On Tue, 08 Sep 2015 17:44:26 -0500, Nassim Gannoun wrote: My question is in a while loop; how do l sum all the numbers in the given list (list_a)? You don't normally use a while loop or a counter to iterate over a list. Such a question should only be used as a precursor to discussing better methods of achieving the required result. As I understand it, the OP was given the homework assignment to sum up a list of numbers using while. Too bad he didn't also specify using binary operators along with while. :) Emile -- https://mail.python.org/mailman/listinfo/python-list
Can't use Python Launcher on Windows after update to 3.5
I've installed 3.5 for all users so it's in C:\Program Files From https://docs.python.org/3.5/using/windows.html#from-the-command-line it says "System-wide installations of Python 3.3 and later will put the launcher on your PATH. The launcher is compatible with all available versions of Python, so it does not matter which version is installed. To check that the launcher is available, execute the following command in Command Prompt:", but:- C:\Users\Mark\Documents\MyPython>py -3.4 'py' is not recognized as an internal or external command, operable program or batch file. Further running ftype shows nothing for Python, assoc just gives this .pyproj=VisualStudio.Launcher.pyproj.14.0. Surely this is wrong? Before I go to the bug tracker to raise an issue could somebody please confirm what I'm seeing, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Lesson 39 of Learning Python the Hard Way hangs (Fixed?)
On 09/09/2015 01:45 PM, John Gordon wrote: In Gary Roach writes: Traceback (most recent call last): File "/root/mystuff/mystuff/ex39_test.py", line 6, in hashmap.set(states, 'Oregon', 'OR') File "/root/mystuff/mystuff/hashmap.py", line 50, in set i, k, v = get_slot(aMap, key) TypeError: 'NoneType' object is not iterable Execution Successful! Where does the message "Execution Successful!" come from? It seems like you have other code that you haven't shown us. In any case, I saved your code and ran it, and did not get an error. No other code. Ninja-IDE tacked the "Execution Successful" at the end if the error message. Dont know why. Interesting that you ran the code successfully. I have tried to run the code in both Ninja and at the command line and got the exact same error message. A note: If you could, please post your replies to the list. If you don't, it either breaks the thread or ends up sending a copy to my personal email address. I am assuming that your email client gives you that choice. If not, I'm not sure how you would assure that the proper way happens. I use the icedove (thunderbird) mail client and the choice is a drop down list at the top of the mail editor page. Thanks for your reply. Still confused Gary R. PS I copied over my code with the one from the lesson and all of a sudden it works. I then used the code I copied to the email. It also worked. Now I can't duplicate the problem. The problems fixed but -- https://mail.python.org/mailman/listinfo/python-list
setenv
hi: This is not a question about python. It is a shell question. I'm sorry to bother you. But I really want to know it. As follow: I want to set a shell environment variable:PYTHONPATH. When i executeecho $PYTHONPATH, it is value:/usr/lib/python/Lib:/usr/lib/python/lib/python27.zip:/var/app/python/libs/pip-lib.zip. Now, I want to add value to it. The value is all files in a folder with the.zip end. For install, directory(/var/app/python/libs/) include gpio.zip, a.zip, b.zip and so on. So I want to add value:/var/app/python/libs/gpio.zip, /var/app/python/libs/a.zip, /var/app/python/libs/b.zip to environment variable:PYTHONPATH. I execute cmd: export PYTHONPATH='/var/app/python/libs/*zip':$PYTHONPATH, but its value is not correct. So, how can i do this? My program use setenv to set environment variable. -- https://mail.python.org/mailman/listinfo/python-list
Re: setenv
On Thu, Sep 10, 2015 at 1:58 PM, [email protected] wrote: > hi: >This is not a question about python. It is a shell question. I'm sorry to > bother you. But I really want to know it. As follow: >I want to set a shell environment variable:PYTHONPATH. When i execute > echo $PYTHONPATH, it is > value:/usr/lib/python/Lib:/usr/lib/python/lib/python27.zip:/var/app/python/libs/pip-lib.zip. > Now, I want to add value to it. The value is all files in a folder with > the.zip end. For install, directory(/var/app/python/libs/) include gpio.zip, > a.zip, b.zip and so on. So I want to add > value:/var/app/python/libs/gpio.zip, /var/app/python/libs/a.zip, > /var/app/python/libs/b.zip to environment variable:PYTHONPATH. I execute > cmd: export PYTHONPATH='/var/app/python/libs/*zip':$PYTHONPATH, but its > value is not correct. So, how can i do this? My program use setenv to set > environment variable. Sounds to me like you want something like this: http://stackoverflow.com/questions/3430569/globbing-pathname-expansion-with-colon-as-separator If that's not the case, can you elaborate a bit on what you're trying to do, preferably in pure text rather than relying on HTML? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Lesson 39 of Learning Python the Hard Way hangs
On Thu, Sep 10, 2015 at 3:27 AM, Gary Roach wrote: > > Python 2.7 (It's going to be a while before 2,7 goes away. There is just too > much code out there. 2.7 isn't going to go away, but that doesn't mean you should learn on it. Unless you have a particular reason for learning 2.7, I would recommend picking up 3.4 (or 3.5, which is about to be released). ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Lesson 39 of Learning Python the Hard Way hangs
Gary Roach writes: > Python 2.7 (It's going to be a while before 2,7 goes away. There is > just too much code out there. The time since Python 2 got any improvements is long in the past, and it will never get any more. It is rapidly becoming the case that new libraries just don't support Python 2, for the same reason. Rather than learning the dead-end Python 2, you should be using the time better by learning Python 3 which is actively-developed and will serve you much longer. -- \ “Remember: every member of your ‘target audience’ also owns a | `\ broadcasting station. These ‘targets’ can shoot back.” —Michael | _o__) Rathbun to advertisers, news.admin.net-abuse.email | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Lesson 39 of Learning Python the Hard Way hangs
On 09/09/2015 01:45 PM, John Gordon wrote: In Gary Roach writes: Traceback (most recent call last): File "/root/mystuff/mystuff/ex39_test.py", line 6, in hashmap.set(states, 'Oregon', 'OR') File "/root/mystuff/mystuff/hashmap.py", line 50, in set i, k, v = get_slot(aMap, key) TypeError: 'NoneType' object is not iterable Execution Successful! Where does the message "Execution Successful!" come from? It seems like you have other code that you haven't shown us. In any case, I saved your code and ran it, and did not get an error. No other code. Ninja-IDE tacked the "Execution Successful" at the end if the error message. Dont know why. Interesting that you ran the code successfully. I have tried to run the code in both Ninja and at the command line and got the exact same error message. A note: If you could, please post your replies to the list. If you don't, it either breaks the thread or ends up sending a copy to my personal email address. I am assuming that your email client gives you that choice. If not, I'm not sure how you would assure that the proper way happens. I use the icedove (thunderbird) mail client and the choice is a drop down list at the top of the mail editor page. Thanks for your reply. Still confused Gary R. -- https://mail.python.org/mailman/listinfo/python-list
Re: Lesson 39 of Learning Python the Hard Way hangs (Fixed?)
On 09/09/2015 01:45 PM, John Gordon wrote: In Gary Roach writes: Traceback (most recent call last): File "/root/mystuff/mystuff/ex39_test.py", line 6, in hashmap.set(states, 'Oregon', 'OR') File "/root/mystuff/mystuff/hashmap.py", line 50, in set i, k, v = get_slot(aMap, key) TypeError: 'NoneType' object is not iterable Execution Successful! Where does the message "Execution Successful!" come from? It seems like you have other code that you haven't shown us. In any case, I saved your code and ran it, and did not get an error. No other code. Ninja-IDE tacked the "Execution Successful" at the end if the error message. Dont know why. Interesting that you ran the code successfully. I have tried to run the code in both Ninja and at the command line and got the exact same error message. A note: If you could, please post your replies to the list. If you don't, it either breaks the thread or ends up sending a copy to my personal email address. I am assuming that your email client gives you that choice. If not, I'm not sure how you would assure that the proper way happens. I use the icedove (thunderbird) mail client and the choice is a drop down list at the top of the mail editor page. Thanks for your reply. Still confused Gary R. PS I copied over my code with the one from the lesson and all of a sudden it works. I then used the code I copied to the email. It also worked. Now I can't duplicate the problem. The problems fixed but -- https://mail.python.org/mailman/listinfo/python-list
Re: issue while doing pexpect ssh
On Tuesday, 8 September 2015 17:07:24 UTC+5:30, [email protected] wrote: > Some where i am missing simple logic :) > > = > child = pexpect.spawn('ssh hari@hostname') > child.logfile = sys.stdout > child.expect('hari\'s Password: ') > = > > getting error as follows: > > child.expect('hari\'s Password: ') > TypeError: must be str, not bytes > === > > Thanks... Hi, can you check it and let me know the way... Thanks... -- https://mail.python.org/mailman/listinfo/python-list
Re: ImportError: No module named multiprocessing
On Thu, Sep 10, 2015 at 7:58 AM, Julio Alonso wrote: > have a problem to import a multiprocessing module. I am using Python 2.7 and > Windows 8. The program (.py) is executed since MS-DOS console. > > If I run the program the output is "ImportError: No module named > multiprocessing". > > If I execute "import multiprocessing" on Python Command Line I don't have > problems, but It isn't useful for my program, because I need to import since > my own file .py > > What do you recommend me?. I need to get benefit from the process-based > parallelism and to use several processors. Did you name your file multiprocessing.py? If so, simply rename it; it should be fine. Otherwise, try running "python -v your_script_name.py" and paste the full output here, as text. Or at very least, paste the full exception traceback that you're currently seeing. The exception gives a lot more information than just its final message, and it helps a lot with tracking down the problem. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: issue while doing pexpect ssh
Hey,
its resolved by small tweak :)
do child.sendline('logout') instead of child.logout()
Thanks...
--
https://mail.python.org/mailman/listinfo/python-list
Re: XML Binding
Stefan Behnel writes:
> dieter schrieb am 09.09.2015 um 10:20:
>> Palpandi writes:
>>> Is it better to use pyxb than lxml?
>>>
>>> What are the advantages of lxml and pyxb?
>>
>> "pyxb" has a different aim than "lxml".
>>
>> "lxml" is a general purpose library to process XML documents.
>> It gives you an interface to the document's resources (elements,
>> attributes, comments, processing instructions) on a low level
>> independ from the document type.
>
> lxml's toolbox is actually larger than that. There's also lxml.objectify
> which provides a Python object interface to the XML tree, similar to what
> data binding would give you. And you can stick your own Element object
> implementations into it if you feel a need to simplify the API itself
> and/or adapt it to a given document format.
>
> http://lxml.de/objectify.html
This is nice - but still quite far from the schema support of "pyxb".
The "pyxb" binding generation generates a Python class for each type
defined in the schema. You just instantiate such a class, populate
the resulting object (in the normal Python way) and either use
it in the construction of larger objects or serialize it as XML -- no
need to worry about special construction ("objectivity.DataElement",
"objectivity.SubElement", ...), no need to worry about xml namespaces.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Lesson 39 of Learning Python the Hard Way hangs (Fixed?)
Le 09/09/2015 20:58, Gary Roach a écrit :
On 09/09/2015 01:45 PM, John Gordon wrote:
In Gary Roach
writes:
Traceback (most recent call last):
File "/root/mystuff/mystuff/ex39_test.py", line 6, in
hashmap.set(states, 'Oregon', 'OR')
File "/root/mystuff/mystuff/hashmap.py", line 50, in set
i, k, v = get_slot(aMap, key)
TypeError: 'NoneType' object is not iterable
Execution Successful!
Where does the message "Execution Successful!" come from? It seems like
you have other code that you haven't shown us.
In any case, I saved your code and ran it, and did not get an error.
No other code. Ninja-IDE tacked the "Execution Successful" at the end if
the error message. Dont know why.
Interesting that you ran the code successfully. I have tried to run the
code in both Ninja and at the command line and got the exact same error
message.
A note: If you could, please post your replies to the list. If you
don't, it either breaks the thread or ends up sending a copy to my
personal email address. I am assuming that your email client gives you
that choice. If not, I'm not sure how you would assure that the proper
way happens. I use the icedove (thunderbird) mail client and the choice
is a drop down list at the top of the mail editor page.
Thanks for your reply.
Still confused
Gary R.
PS I copied over my code with the one from the lesson and all of a
sudden it works. I then used the code I copied to the email. It also
worked. Now I can't duplicate the problem. The problems fixed but
So something was *necessarely* different between your test and what
you've posted here (which works for me as well, without error).
Your first tests were different from what you've posted, this is
certain.
Could be because you redefined "list" in your module, you shouldn't:
>>> list('abcd')
['a', 'b', 'c', 'd']
>>> def list(aMap):
... """Prints out what's in the Map."""
... for bucket in aMap:
... if bucket:
... for k, v in bucket:
... print k, v
>>> list('abcd')
Traceback (most recent call last):
File "", line 1, in
File "", line 5, in list
ValueError: need more than 1 value to unpack
So if you've been using "list" as a constructor *after*
def list... *in your module* it wouldn't have behaved as expected.
As a rule of thumb : do not use types names (list, str, tuple, ...)
as identifiers in your code. Most of the times it is harmless first,
(especially in modules, because of namespaces isolation) but
sooner or later it leads to strange errors...
>>> list(message)
['h', 'e', 'l', 'l', 'o']
>>> list = [1,2,3]
>>> list(message)
Traceback (most recent call last):
File "", line 1, in
TypeError: 'list' object is not callable
--
https://mail.python.org/mailman/listinfo/python-list
Re: From logging to files to a better solution: syslog, Sentry, Logstash, ....
Thomas Güttler writes: > ... > Why we are unhappy with logging to files: > > - filtering: We don't want to get INFO messages over the VPN. You can quite easily control at what level messages are logged with the standard Python logging framework. Each handler has a level and will ignore messages at a lower level. > - Rotating: Rotating files is possible, but somehow cumbersome. There are standard tools to rotate logfiles. > - Support structured logging of values (json) in the future. Again, the Python logging framework is quite flexible with respect to the format of logged messages. > ... > Which solution could fit for our environment? I work for a customer with a similar environment (he uses "Zope" instead of "Django") - and he uses logfiles. The logfiles are automatically rotated and there are in the order of half a dozen to a dozen logfiles per day. When I have to analyse a problem with the help of the logfiles, I do not copy them via VPN but do the filtering remotely and only copy the filtered portion, if necessary. -- https://mail.python.org/mailman/listinfo/python-list
Re: Getting response over logging socket
Larry Martell writes: > I have an app that uses the logging package with a SocketHandler to > send messages. Now I've been asked to change it so that it can receive > a response for each log message sent. It appears there is no way to do > this with logging package. Is that true? You are right. There are different connotations associated with the term "logging". One connatation is to inform related parties about events of potential interest in the current execution. The parties may or may not be interested. It is of no importance for the current execution whether some party has processed the event. This is the model, the Python standard handlers adhere to. Another connatation is used for transaction management. Those systems often use a sequentially written "log" and some operations must only proceed after this "log" has definitely been updated. For this type of "logging", you need a feedback that the logging operation has completed successfully. The Python logging targets the first connatation. For the second connotation, there are likely better approaches than the standard Python logging framework (look for "transaction", "transactional"). > Can I not receive data over a > socket used in a logging handler? Almost surely, you can develop your own logging handler which performs a handshake with the logging target. Note that the logging destination, too, will need to be modified for this. I assume, however, there will be better approaches that using the Python logging framework -- e.g. transactional safe message queues. -- https://mail.python.org/mailman/listinfo/python-list
