Why do these statements evaluate the way they do?
I'm trying to figure out why the following statements evaluate the way they do and I'm not grasping it for some reason. I'm hoping someone can help me. 40+2 is 42 #evaluates to True But 2**32 is 2**32 #evaluates to False This is an example taken from a Microsoft blog on the topic. They say the reason is because the return is based on identity and not value but, to me, these statements are fairly equal. Can someone clue me in? Anthony -- Sent from my Android device with K-9 Mail. Please excuse my brevity. -- https://mail.python.org/mailman/listinfo/python-list
Re: Sending an email with a binary attachment
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 03/01/2016 02:03 AM, Chris Angelico wrote: > On Tue, Mar 1, 2016 at 6:58 PM, Anthony Papillion > <anth...@cajuntechie.org> wrote: >> -BEGIN PGP SIGNED MESSAGE- Hash: SHA512 >> >> On 02/29/2016 11:13 AM, Chris Angelico wrote: >>> On Tue, Mar 1, 2016 at 4:08 AM, Peter Pearson >>> <pkpearson@nowhere.invalid> wrote: >>>> try: smtp.sendmail(message['From'], message['To'], >>>> message.as_string()) except: print "Message sending has >>>> failed" sys.exit(1) print "Message sending was successful" >>>> sys.exit(0) >>>> >>> >>> This is the problem, right here. Replace this code with: >>> >>> smtp.sendmail(message['From'], message['To'], >>> message.as_string()) >> >> Hmm, I'm a bit confused. Are you saying that the problem is that >> I'm enclosing the code in a Try/Except block? Besides that, I >> don't see anything different. If it's the Try/Except block, how >> do I catch the exception it might generate if I'm not using the >> exception block? >> > > That's exactly the difference. Why do you need to catch the > exception? All you're doing is destroying all the information, > rendering it down to a blunt "has failed". Mostly, I catch exceptions for two reasons: 1) because it's a habit that I've developed over the years and 2) I think unhandled exceptions make things look ugly. Mostly, I catch them from habit though. > > You should catch exceptions if you can actually handle them, but > if all you're doing is printing out a fixed message and aborting, > delete that code. Less code AND a better result. You make some very good points. It's going to take me some time to not catch exceptions by knee-jerk but I can see how doing so can cripple code and make debugging much harder. Thanks for the pointers. Anthony -BEGIN PGP SIGNATURE- iQIcBAEBCgAGBQJW1mwTAAoJEAKK33RTsEsV0L4P/jvRCX7w+8iqzlFub0CS35C6 KtuFXLEh+evKGhBecgToCA9eutuvCltknCxJz/Yyd56+QFsze1HHdDWGakuOP/1x gOwzZKr1vsjD4eMkoRRokIVkg437yOju0OReUOATKpYGgwnB6xW9RbOLwHRftXfa pmxg5k2KCBZ1omVLQ1BQcvM48Vi5J4k6IlFAVyM/L3Dzsyj9E1CtJ/VarTwkmAOf RbrBV7EH/k1ELM6yWsm0P00zhQkwZTdKt+Y3OGj7WaYoZXk7D3Q8wJqOJrHgInCr /JjbjX8yHtcVVaIRPKGVGt5PGNDdGvkmI5mJPXL+Io0k8faA4QLqjdCTFniyJ2t3 6HprovGQOJs64WN9RshcCwncJcWLC1wcLWZhZOj9nNZawTM6pWEDFpn1zmg6/lqu DmqhEeudjUtCjRJZr9xey47JJRRkjUrh/g1+VRW+aUfeuIc7xA6Nw7qvf3PqT6tH 8CtVwK9O2sHQ4y8lzAK3vCYY3Lw34qdO2zBC0ycxhMPbk1BqcL5U4WOTDZD/9H3h sh0E19pLYsAtoJpF2tnB2PcJaIWA9Zofz5/K6+5fs5B1wVW34Nu8wz6LMhUR1qSW yJH9Wv8Oznk99qiYUiOiduqGKwLM4+Fg0xYAX1muGNRvLfcYuGDFkyYhdZn9f7dM QdmK/dIaGT9l45hjDQTu =RlhP -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Re: Sending an email with a binary attachment
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 02/29/2016 11:13 AM, Chris Angelico wrote: > On Tue, Mar 1, 2016 at 4:08 AM, Peter Pearson >wrote: >> try: smtp.sendmail(message['From'], message['To'], >> message.as_string()) except: print "Message sending has failed" >> sys.exit(1) print "Message sending was successful" sys.exit(0) >> > > This is the problem, right here. Replace this code with: > > smtp.sendmail(message['From'], message['To'], message.as_string()) Hmm, I'm a bit confused. Are you saying that the problem is that I'm enclosing the code in a Try/Except block? Besides that, I don't see anything different. If it's the Try/Except block, how do I catch the exception it might generate if I'm not using the exception block? Thanks, Anthony -BEGIN PGP SIGNATURE- iQIbBAEBCgAGBQJW1UuZAAoJEAKK33RTsEsVdfoP+N/xBIMouhhS1pqInvd9wrk2 jCfjmk7aHQQOdSvtQjXEqdNUu6nPmvX9VRzqvs881bUZAx31usL7VnyzJsL89pZl PPrXG3WzEDkMaWmfZ45/irGwuP3Cpwkw3h7raDcvA/kV7+jLUBq//1kW7itofPh8 6xKJ9yCJ35vCS4LDhEeIbtMQXRe27QQXeFfi2VjFFRQRQeJlKf0nAd8sH/4q1fPa IVKy6lgZcDDzCzy0Ux9us8baUOgTjLIY81AKMXGUmXaUNLpDfF6n6RLRtj8fLcN5 sT37okHyRmK9LNwI1PzU8r2p7i3gweDXx4x9g6nqmi6OV8fm4suSd8VOWb8oF1Yb clQWSvSPE3GcnVaepcixIV1PCF53KsCHaPp63RZbKB3MiPuNTdQQi9Xm1Qfrt0UW uJiEzfGXavkNRYaShycMB6HJGfjIsCZH9wzf1/irCuhiy+kJbvQq9lhojWw/V0N3 TGwY0Sd/eWqtmcx+u449viDIfLZsJDjzXXsYV60JdZtsSsd5+Mud+vfOlv3s/oy0 EPnIzMJar5LGPghPuab8g7rcXim77hFxS7eLp4j9ugWgRPa8TRpiBb/wx2c8a2e0 122ZW8Fc7+9gxHxSCJdM7GIFChdN2IMogCkERAuTyo+dNP01Mv07eMvSA6JkgiN2 ZlSJ8M9UHRS7dplpJGE= =nxc8 -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Sending an email with a binary attachment
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hello Everyone, I've been trying to write a /very/ simple script that will email a binary file to an email address when run. Pretty simple. I've done quite a bit of research and have finally settled on the following code: http://pastebin.com/sryj98wW For some reason though, sending mail is failing every time. I've made sure that the password is correct (which seems to be the most usual error). Still, I just can't get it to work. Can someone take a look at this code and give me some advice? Thanks! Anthony -BEGIN PGP SIGNATURE- iQIcBAEBCgAGBQJW0/zYAAoJEAKK33RTsEsVH5YP/jisLkuK4SAD6E06dO/czn1V bO1QlzqTje8giXUWGyVeGS9MHAA1S2TlHc/rp01/DHTt1iYT50qGIaPxzUxBTMEX mBCFFUSgg6LjkY+9b0c+o4OmviZlX7/KA6wT9IpFEG0l86Uj+z39rcBHm+GauiX+ IgMS5lWXfPmIEwiKzByMduxEgfj6kQW6PhkR5hTmOvd3sbILR91U9NiigrUD1ukM +eN4LnKVu5Qpyb8X34Ze0NF7tiMr7tTQyBIq6C6ORGR/IPri407Ro8ACHBd55xZV QxHjFVemms9s7ala0aoBcpRKr4PG35Ebm+7CcZaDj0fdk11mRvpqCZtGfodw/+sL Crrxoz11hC//DHslZrEuNlJHgRqnsw+abKG8jIaJCrIW1f9BiyiWse+RRwbpN8IY 1C0gD4E1N3dUqGFrhyD/Xuy0tkXWpfiYhcLJQY+j7exrf00s+ASUTrd92lDCzxW4 pwuPZYN6nXY6dh9q72fgoEzqU0eDIzSgX99fODcxqp1L2ieczWMMajlWQJrJEcUe UgxB8IvlvuD3NpzZXisEG8ZzqhZT6GOurHGbBusAW2M9zaqImb4qGEid7HS4BL/c Kj7PspXz+8gD3SKZ/dOBdFlKK1KM1utekB0UnmBboZ9nXVhz5qVPaiVgjPunB5TG 1fMuuGiy2yl5pfTNvH8a =Ff+J -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
I would absolutely recommend you take a look at the Qt stuff. Very modern, easy to use, and free for non-commercial products. Anthony On February 27, 2016 5:18:57 AM CST, wrong.addres...@gmail.com wrote: >I have some VB forms with more than a hundred objects. If I cannot drag >and drop text boxes, list boxes, labels, etc., it will be too much work >to create that with several lines of code for each object. > >Isn't there any good GUI IDE like Visual Basic? I hope there are some >less well known GUI IDEs which I did not come across. Thanks. >-- >https://mail.python.org/mailman/listinfo/python-list -- Sent from my Android device with K-9 Mail. Please excuse my brevity. -- https://mail.python.org/mailman/listinfo/python-list
There has to be a better way to split this string!
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hello Everyone, I am using datetime.now() to create a unique version of a filename. When the final file is named, it will look something like: myfile-2015-02-09-19-08-45-4223 Notice I'm replacing all of the "."'s, " "'s, and ":"'s returned by datetime.now() with "-"'s. I'm doing that using the following code but it's freaking ugly and I KNOW there is a better way to do it. I just can't seem to think of it right now. Can anyone help? What is the "right", or at least, less ugly, way to do this task? Here is the code I'm using: unprocessed_tag = str(datetime.datetime.now()) removed_spaces = unprocessed_tag.split(" ") intermediate_string = removed_spaces[0] + "-" + removed_spaces[1] removed_colons = intermediate_string.split(":") intermediate_string = removed_colons[0] + "-" + removed_colons[1] + "-" + removed_colons[2] removed_dots = intermediate_string.split(".") final_string = removed.dots[0] + "-" + removed_dots[1] return final_string Thanks! Anthony -BEGIN PGP SIGNATURE- iQIcBAEBCgAGBQJWupG0AAoJEAKK33RTsEsVVJEQAKZEk5jolpxa4plDvW6rY9ux YdXHxtBa3emLprVMJTAg6+NJLZaeBjulttWv2Vy1y2tE8j1prLqHVtzITdX5kVG5 z0VUZgLRYi9Ocfk5vz4lGsWEWwRtkUQrpodbXqCArerUkBqHEW/Bgs2PGq9FGbNP 6QCWLsNr1APkEl5q8P3QCM7x1z0nsQKsbVMdvNjfi2kzsvDIm6lXgl9uUFxOFesp fUkuiLFHFpbIRnnMke2mLahXWyN14QNmw6OOkqG963gOjecfC+2dNozAOSf42ul+ s2p9h3BiwijMvU/nvc/6jR3uFmoE3dIcGWsyYFNPWnPvrHUy0qHIgcavWDEo3+cw J+qOYSX3XlTIrGc5ZJKdJWs6FH7d1+WZ4GndSj316LAKq0XN46rq/ppJksStpUwU I7Gmk9mAnRt9uZy25xsx93jY8IiiOKDmI1cTclo/UKAYvQk8ib/allLnVZrssmsc 2hgugwBe6R966wavdrYl/yt1VlfwRdImRUL6pTNnCDMYYcJS0F7ATJ/dWV9iRD0h PiIiB6zB61EyKw1djBRQ0F8XqxNZK0qR0UMR5hPWJcHRp3y94bgl2tI0/aMXmFW+ jiwQ4ecNgqb9k2C6iok+9OXJ3YoqToVbXFS7/svXpS88giksS+Re+5RChxZGSWSd gXhYvKEHs+2l3Vuyhdsr =8uK+ -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Re: [SOLVED] There has to be a better way to split this string!
On 02/09/2016 07:26 PM, Anthony Papillion wrote: > Hello Everyone, > > I am using datetime.now() to create a unique version of a filename. > When the final file is named, it will look something like: > > myfile-2015-02-09-19-08-45-4223 > > Notice I'm replacing all of the "."'s, " "'s, and ":"'s returned by > datetime.now() with "-"'s. I'm doing that using the following code but > it's freaking ugly and I KNOW there is a better way to do it. I just > can't seem to think of it right now. Can anyone help? What is the > "right", or at least, less ugly, way to do this task? Found the solution in strftime(). Exactly what I was looking for. -- https://mail.python.org/mailman/listinfo/python-list
Re: [SOLVED] There has to be a better way to split this string!
On 02/09/2016 07:47 PM, Ben Finney wrote: > Anthony Papillion <anth...@cajuntechie.org> writes: > >> On 02/09/2016 07:26 PM, Anthony Papillion wrote: >>> I am using datetime.now() to create a unique version of a filename. >>> […] >> >> Found the solution in strftime(). Exactly what I was looking for. > > For the task of making a unique filename, you should also consider the > ‘tempfile’ module in the standard library. I looked at tempfile. Unfortunately, the filename has to be both 'unique' and 'identifiable' to the original. So if I am using mydog.jpg as the source and I am adding something unique to it, it has to still have mydog.jpg in the filename. Tempfile, I think, doesn't allow an easy way to do that. So I'm just adding the exact date and time which is unique enough for my purposes. Thanks for the pointer though. Anthony -- https://mail.python.org/mailman/listinfo/python-list
Getting data out of Mozilla Thunderbird with Python?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hello Everyone, I have a TON of email (years) stored in my Thunderbird. My backup strategy for the last few years has been to periodically dump it all in a tar file, encrypt that tar file, and move it up to the cloud. That way, if my machine ever crashes, I don't lose years of email. But I've been thinking about bringing Python into the mix to build a bridge between Thunderbird and SQLite or MySQL (probably sqlite) where all mail would be backed up to a database where I could run analytics against it and search it more effectively. I'm looking for a way to get at the mail stored in Thunderbird using Python and, so far, I can't find anything. I did find the mozmail package but it seems to be geared more towards testing and not really the kind of use I need. Can anyone suggest anything? Many Thanks, Anthony Papillion - -- Phone: 1.845.666.1114 Skype: cajuntechie PGP Key:0x028ADF7453B04B15 Fingerprint:C5CE E687 DDC2 D12B 9063 56EA 028A DF74 53B0 4B15 -BEGIN PGP SIGNATURE- iQIcBAEBCgAGBQJWZx+3AAoJEAKK33RTsEsVVa8QAKf1AmFdJsi4/b08vpkfwP3c akGV98EuZzEva29jr8nnfXGgqw7xD/nDjMyLzuO0/q4Kn7eKpEnxkcGDLSbDgxaW O8kD5eALHCVlUp9p/h7RMBBAyZ4mH8YC6qwvd5SWtH0TIMR7ClcWmDYwPF1Ahk7n NAFvTsMl8PSnhcIoWHE4vebN4wHR8gZAxOLI8WVPA2BbER64EXiL00nWBav6UDN5 NUosAAVa549rrH0ibEf7Lada63DRTHCYnESxNIkAAHIO0z69WjnfZQ8gmmGFhuaW AZzqYV5pIhdRnvrwjCQ06LtUNtz/qPqLbLSWF0hA6lwPKqzNum9EdvS4c1xjcXsU KpOCTmJXy40x1Oi8h+yT6PGiDxt5VCHCdN8ppToI3HY5pYmoiPgWszJzrqYMz7hz ruhNFAksKNUSI9QQupYcPw6oKQdnoGWmBH1yvGlZqeZuIxhGEv87oqRISE4NRQLe yL4aDebwXdDgBzIZvFOFy2W4L43jdravg2/LliSC18iCUKBnIpWhazy7NZHw6h55 h3QP84DeuB/9tPLQUZF+BEJm3I+V8WfSKVVnsSbk/n/chHgYpWnu+h/wpD6lx43x y0lPJm0ni5LeQM1bK4TsIXVEAOzl8UaOwn/VUG7P6Jnt6VEqvQutWZ0/WEeP1nIX M7+e9hLlQWtlEbl6ud1K =Dz7N -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
How to create a folder using IMAPLib?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 I'm writing a program to help migrate mail from one host to another with a few special circumstances. I'm able to get a list off of the source IMAP server using the .list() command but I'm not quite sure how to create a folder on the target machine. Does anyone know how to create a folder using IMAPlib? Thanks, Anthony - -- Phone: 1.845.666.1114 Skype: cajuntechie PGP Key:0x028ADF7453B04B15 Fingerprint:C5CE E687 DDC2 D12B 9063 56EA 028A DF74 53B0 4B15 -BEGIN PGP SIGNATURE- iQIcBAEBCgAGBQJWTNkwAAoJEAKK33RTsEsVWsUQAKwo8HkE1mCDr+fFMQhUoE9N Tb80bbZkERbY7wvy31sr9EIBVDan6KDk7ZJX/hcYMfjOmoOtq55Ywmb3UxEkLzh2 TK1uujPa3X61hOYquspQ2QQ3wPW0mIEf+dTSQGipRV5n/AotIMD4Wda5Qia3E8ak tcNqXmi9k6iQoW1ct3JWO2HScJL5AUAcnu/C/iFsC1oGWGLYFu3fXOkjExN3GBTg ihuiyHAtUsow6pMLuRQ61/HHU9c3G2laOs/4M6oRtsnMetANsxi7BAP/X+OBxCdA nz1qe2SORoFs/UYqbFkwJOvBDLTTrpyLv9ZvqWwdq1IUngMA1p/sJxRkYZ8bL6Wj zJVJxDSxkE5s6J/neqFA97KI8EVGX5DXS2lNSxBT5crJkF88brBcUvebx0Euogdk Jqk/rtRE1D6nFa+q0Og4A32Ajg0Qbr2prKcgxW8QxHuOEx/yuUkOpC9znW3qJ6uh D60b1tP03RasdfQEnoaKI3Z0+nKulBFVZW5iIQKTZgp+2Vqr3umodv4PUcz3wq5g nVRbtAu5pS904Jt+mr64DGW2ssBrYGl5HEwRG83r0coXgpO+GR0kZNZ9CoQtG4xl wF2wTL8PqvJNqBamQ5KJi8Mqeb2FkEc8hgfy6EtUPfOAs3zJkbQv1Q3IcGT8UvRL 8UAGdPsn1LQ51BVDLaZ4 =77Lm -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Creating PST files using Python
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Does anyone know of a module that allows the wiring of Outlook PST files using Python? I'm working on a project that will require me to migrate 60gb of maildir mail (multiple accounts) to Outlook. Thanks Anthony - -- Sent from my Android device with K-9 Mail. Please excuse my brevity. -BEGIN PGP SIGNATURE- Version: APG v1.1.1 iQJJBAEBCgAzBQJWOQZSLBxBbnRob255IFBhcGlsbGlvbiA8YW50aG9ueUBjYWp1 bnRlY2hpZS5vcmc+AAoJEAKK33RTsEsVwdgP/1f15VCI0GKkM54ram8oL3Bh2e5s PqxhS/qe+9pYwYZrt+Dj2EENtpdwVQxIin67WxsruE1hOYcrrZiURiCaav8aL//3 zMiBwtEIHrYZ+0s54rfQTx1eltlET3c9O/Hehh69TtuLWiCYp1fKUW7pJEV2ZnqV jLoGLeQ1BkXCukVeRVm8W8q7aBycF9jLP/Hg7r7p7g1RUYoIfUCOd0833AAHrbb4 CpSgvsztUfK7mJR9yxcWl4QPFTq3wpZA9MnXqnS/+UxqLSVRJp66omYn31w1AqQA 7XTuP3TQ4GjhPJC6uGiQUNQslBWj5FYRUQxlH/CzUFMeLpbK+ruG8K3QyNG8tFpj TdUNxeWeRl+Sf5elgDYDe4Farn82ZborOlZmMspy/S87tENDgs1rND9/wIgnXtrt g7sK3eVkmbBXkIqA9xXwkmx5GyHn3+o5a8JhFihePy5XnvlfAsnhjzsogTN3pYdO YSKqR76cTTLzYuOjiF61DIgY1R/HqUsiloGiVXjfghV+ADcFLhADIJGa7wKwSItv TjZmUKjF2U7CaNqn6mTR83VdtOymeoQyTZw9sB0WmsVVjVinOuExyy3qa9D3E07D yfaa/RVgGLw6ygq/8JTXQx8B8xJ5lOl7KBxVNqaS9Kwx14F3aQdrDqvZRDCpU7U5 X/FC8f6YIksLIX7y =254i -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Re: How to handle attachments passed via Postfix
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On October 13, 2015 2:04:09 AM CDT, Burak Arslan <burak.ars...@arskom.com.tr> wrote: > > >On 10/13/15 00:52, Anthony Papillion wrote: >>> Check out the email.parser module, or the convenience function >>> > email.message_from_string - you should be able to get at the >>> > different parts (including attachments) from there. >>> > >> Many thanks! Checking it out now. Sounds like exactly what I'm >looking >> for. > >Also have a look at flanker (https://github.com/mailgun/flanker) >basically doing the same thing. > >Here's why it exists: >https://github.com/mailgun/flanker/blob/master/docs/User%20Manual.md#rationale Thanks Burak!I've just had a look at it and it looks pretty amazing. I particularly like the speed incest and smaller memory footprint. Thanks for pointing me here! Anthony - -- Phone: +1.845.666.3312 Skype: CajunTechie SIP/VoIP: 17772471...@in.callcentric.com PGP Key: 0x53B04B15 Fingerprint: C5CE E687 DDC2 D12B 9063 56EA 028A DF74 53B0 4B15 -BEGIN PGP SIGNATURE- Version: APG v1.1.1 iQJJBAEBCgAzBQJWHM+8LBxBbnRob255IFBhcGlsbGlvbiA8YW50aG9ueUBjYWp1 bnRlY2hpZS5vcmc+AAoJEAKK33RTsEsVmCQP/3KYdbTjyXW33BkCalagLosJC6os xGVggx1TB8aK0QFDAJoVRAKZ7nn9AV75VC/+Y9qIVJyMWS9GQICMhU29NeSJ7Uao DL6XqROpOy8hl9Mnu+e5c0TwL9SI2oKeOwRqxwJVVWq9kM/og99ryfKOaNIVBoV4 32gHHYqjEx/zXlmYTL0gTbYbK/LJyVlmfVYWXjdvb7QWsv8g+5NyRUpqKrx+Pvvs YPhtfQ/ltgo7NxSU2e3hNWp91F29J840d82jvHVqPEMpAHVikFBYAD8B1fkeLvBi z9x5mQfGdReLlnUngbCcJJ0/6Vwla5LeK2nvAJuMofjy2NKCS91arLmp5wIgWz7P CMSep1Lt1Nhd1PRKMF0uXFMZ1i7cC7BzalyY6WJHnFBryLh0uxrEMH2ma1ZR+d7W PgcMo4nmB9ECIbZAGQE5p46QJ08op8E5GnrtRfOlcCpJIYLT2CEIg4cSz14cPm8f 0mCP7iMz3B5CeASTnfJ425mTczHVgtd20FpiRNUh58JvoSlLL0nmRaL4yJfBlC+t u75UsNxknWPsy3tDCDs2U+gdo0vrla0Ld5iy2i38oiJ0a9KBeUiLrJd7AJi4fQft BPJHDdRbUBXnpkb7VyPLF7ftxEVvI/XxJr8NY99DU/hfexsOiY/49YFdj783GxDk FuzU9Vmd1HAeou0T =JVUd -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
How to handle attachments passed via Postfix
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 I'm writing a script that will have email with attachments passed to it via Postfix. Postfix is properly passing the email to the script but I'm not quite sure how to get at the attachment. What I need to do is save the attachment out to the filesystem. Can anyone point me in the right direction? Thanks! Anthony - -- Phone: +1.845.666.3312 Skype: CajunTechie SIP/VoIP: 17772471...@in.callcentric.com PGP Key: 0x53B04B15 Fingerprint: C5CE E687 DDC2 D12B 9063 56EA 028A DF74 53B0 4B15 -BEGIN PGP SIGNATURE- Version: APG v1.1.1 iQJJBAEBCgAzBQJWG16OLBxBbnRob255IFBhcGlsbGlvbiA8YW50aG9ueUBjYWp1 bnRlY2hpZS5vcmc+AAoJEAKK33RTsEsVfr8QAJDmU9lroSDdVkvLNoniwq4j/UM+ 2KOozruO8NKciYFLuKpip006Tza+XQxmqXjIi/KxXuXaqu+bQaigem9/eo2AKQ4n hSzs4sjQdu8Z2KBOxRaItSzCypdCEKFHQkHjne7d+vH1QA0XpL1LbBhliUjRZWNV LrjsLmJwggD7ClRPfQKfqK9Jr0l772EGZZlEbH9gLRvwoHTcZb9qm6iQObfXnEjt HGnTQpnRet4GOrx/GjFKzcnUxEhR5HtyqIMYp06miGEk6zTEWmtDRizCKCaF/GPC KdK7RZJvugQnNC4lohyD9Wa686t157lRQNZHkfNBhbqcSTko7QwRG7A+rca628ON L4rpcz68ruVyV7XQBtcaQcKcn/yZHcaTGpBUVIgIOGtnyxuDhJnTZiiXjUXMc8tj 700sgTHlrsiiJkjed9FEfoAOt66WNcaVsAR/jirSSyyMwSTqxxbOHzM/zOK0Whq3 8SD4kMAvjlAqU96ymy0rUuf4hvoyJ+aiit27ISxtofW+Lxn8vDMSYja5X/vBActZ ZqP27NK+xSwfUXtdZ/CLkYqIBs+Bi2nQamHqN6qZSe1oS0WSG6zHf7FO2Br8bBJ/ FJlqWV/OTSrU85SRIJ3OeSKWD8oCizEpsfS5P/8dCPYJGfY6Yk9POOebH1H+SP4D nhO3G81QosenmGhZ =n767 -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Re: How to handle attachments passed via Postfix
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 10/12/2015 3:58 AM, Chris Angelico wrote: > On Mon, Oct 12, 2015 at 6:17 PM, Anthony Papillion > <anth...@cajuntechie.org> wrote: >> I'm writing a script that will have email with attachments passed >> to it via Postfix. Postfix is properly passing the email to the >> script but I'm not quite sure how to get at the attachment. What >> I need to do is save the attachment out to the filesystem. >> >> Can anyone point me in the right direction? > > If I understand the situation correctly, you're getting a > MIME-formatted email, and want to decode it into a usable > attachment - right? > > Python includes a package for teasing apart RFC[2]822 format > emails: > > https://docs.python.org/3/library/email.html > > Check out the email.parser module, or the convenience function > email.message_from_string - you should be able to get at the > different parts (including attachments) from there. > Many thanks! Checking it out now. Sounds like exactly what I'm looking for. Anthony -BEGIN PGP SIGNATURE- iQIcBAEBCgAGBQJWHCufAAoJEAKK33RTsEsVfeUP/3YWWDwVglwHXkHGrY3AkWol yyTeJyy+s8RQvza1gHcR3yv2gZs7PAI8azFjkMmlsicaB+dqdP1ffxd2eXK3TVlh GTOuCe7dHNgJ4EMpREr3RtJVbvQBX3ygmZaZY9jqPRCpG40TfOCaEOXjGABLukwi DP9j65tyIYRJsImmQ4RJ6L2AcrgGC3QTU1wCPPWaYD9AWLFyfR4be02vGGZODbYs QnKw1MrHrQBWMYaVKlhkvHVJIa68q/wIH4yPfE8tPejykRQ0OFUDfp8a9zveNU7U zIjeVU02jL3ijGXK1LxNz3mtt+aRletecOFbLtCMLY9TLwGTquXRyQzl28oOukh+ Uy/rYf9ZK8g2qrOEELyJXy4x0K6MpTdF+hN85oYkCl802uEsqlxUsU/EocUs6uIX GIXrevDSvdQDbujMUPg4TQKmkhNN5/fC40NQGFd/xcxljTqHZ/bl4MinDT9ZxYFk OLwEpCVZfTMJvYxGEfBS1GQvKxeRKzPgXeV70YgXh0GIl339Bq1znpObnlYNuVki cBRqos2RUAanzgkQ6jqoE0KknP/wPZL/nJA1MR67lV64j5zqMD/b+Pw44K/u9QNP YZnXzto8EUJ9Zs4i7LrZcFuRpE+WjFyP39XPGiMZN7+/S9++CVfgu0SLLT3VrHWc v7WzAa3wNEnR8O35bhvH =xwRy -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Is there a Windows Python SIG?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Over the next few months, I'll be working on a project using Python on Microsoft Windows. While I'm doing this project, I'd also like to contribute in any way I can to making Python in Windows better. Does anyone know if there is a Windows SIG? I went to the Python website where I thought I'd seen one but it doesn't seem to be there now. Any thoughts? Anthony - -- Phone: +1.845.666.3312 Skype: CajunTechie SIP/VoIP: 17772471...@in.callcentric.com PGP Key: 0x53B04B15 Fingerprint: C5CE E687 DDC2 D12B 9063 56EA 028A DF74 53B0 4B15 -BEGIN PGP SIGNATURE- Version: APG v1.1.1 iQJJBAEBCgAzBQJWFfvuLBxBbnRob255IFBhcGlsbGlvbiA8YW50aG9ueUBjYWp1 bnRlY2hpZS5vcmc+AAoJEAKK33RTsEsVWbQP+wQesUBBum1FvswZqav3HnSDxKJ0 tkytRhaXCEtAwK5OShYyK9ktxUb7P3gCKCZix30UegtW9RcXqvqSCq/aWqKCtV0Q yqV8Jcr0cuinIMWLLIEWNZolERStMr2U2HVL0tAXvVwYqvAqfEbWm+akSFbAy+s4 J2ta3gnynD5jIkh0BlLFOBxqg06EbSY0pO8o0K1rEtSGBY2IjXElFwQnJ/IwvxHq x2a0SUGaGrlFCWoJ7agHIS0kZOZonn930U4QHdf1fLNWtQq8t9xy5qIV2PCn87m9 YxnZuWY+XuFO47Z5lS++lZFkwE9pu6PKjzusyZQ/BQlkh5QjtuJhjUSMA8ZaTPIO L3P3aun+cKNTEROMN95b4ygiVWljY6QVwGVxdcxbyudisIdnNaaG6+gtNJ7HKbgG BHH+3w/BQ2MdX5dhQrDBbBFLNcUBP2/HT470bf4UY8cXssB0ZfkOtMCxsKA5XP8U 8sZ2KHEMV7doD7SvHNgeg5PUwl+p98ymHgoSZqfq8W4A24Ltk8RvIQZjIOioEY1G kAzUyx06JjbcOlxGtP0Wk0+4v8NGzu2agWWQQgSHSaYpb4aOdoQ28ryYi7srd8gP vRYRpBYQhoAIClwcfaoO0pQnfnSf0V6lpnBJ3/gNCgW1F+RquvN285aD4BlPj3N+ MkwZBgzxIx4ybh17 =xqD0 -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
How do I real a SSL certs serial number using Python?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 I'm writing a simple tool that needs to read the serial number of a remote SSL certificate. I've poked around Google for a bit but can't find anything that fits the bill. Is this possible in Python? If so, would someone point me in the general direction of how to do it? Thanks, Anthony Papillion - -- Phone:1-(845) 666-1114 VoIP: 17772471...@in.callcentric.com Skype:CajunTechie -BEGIN PGP SIGNATURE- Version: APG v1.1.1 iQJJBAEBCgAzBQJV6FtfLBxBbnRob255IFBhcGlsbGlvbiA8YW50aG9ueUBjYWp1 bnRlY2hpZS5vcmc+AAoJEEKq2nfie1EM5EIP/jUdLg03pPWksQcXOqiMtYAW65E8 43J5yYgJmjTM7a87s0CyYhKxJN9VO/trBptCPvowrwZ9AdDbPxQUzRvSni4Trzfh TTZi0K9rpoKqUcwX+z2EwRWDlyiDKWpq7DzdisLmqACL02pz/xQcBM/LPj9TvhKB NYhIY0jw4S0oISMWz/eqVyCd1RMHvxsDOM3wKVbwXKN2r5Bx+AC2F2S0qOneUcNX f9GNhbjDKleQPifrBQ2q3k6hnUaUbATELUHqsa3/p3/UIVv8OZ7ONKe17Ofh8Cxf 0mtmMuH7a5gAeCwwPQnU/nI6g9QXEDv/yRdqWX3bi11xw88jmMEBq2ybQyvAiAmm 2Czphjk87tkbdrYu6QKxLFLmaeAh8scl2XOlk+X8+hVasiG/px0nvvgPSy1s/nC8 pEMIiyUoFliq6IszuMshzHU6JCmvBKP0AmoVIodnJal1rR7vh2aoh9tKU92nrHGV e33tdP8JobfmFHQesHVUZVBvdsxO0othuQKKADMdmm31BfrSEydNdcA+9aTXwbUT ef8sz5eu7MzUu4aq63k/qwyaflP/TBNhTk6ByePvI/g4l1gDxGHskAt8tPBO2gT1 rTKYLOk2ckFh4TutD0IvdL3EyyxzrhlSfprjUJV8X3RWcyYDooPQN+STG4sBJUC2 vAc5oUGXdaHIWsbd =oAPu -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Re: What killed Smalltalk could kill Python
On 01/21/2015 04:35 PM, Chris Angelico wrote: On Thu, Jan 22, 2015 at 6:18 AM, Grant Edwards invalid@invalid.invalid wrote: On 2015-01-21, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: In 2009, Robert Martin gave a talk at RailsConf titled What Killed Smalltalk Could Kill Ruby. But does he answer the more important question and can we use it to kill PHP?. PHP won't die so long as there are people willing to apologize for its every flaw and defend it on the basis that huge sites X, Y, and Z all use it. But we don't need it to die. All we need is for Python to live, and we can ignore PHP and write Unicode-aware web sites with simple, trustworthy entry points, and not worry about the rest. To be fair, PHP has come a long way in the last few years and, I hear, there's movements within the community to make it better. Namespaces were a bit deal as were a few other things. Personally, while I am LOVING Python, I'd be sad to see PHP die. It's got a lot of potential if the community can get its crap together and take off the ruby coloured glasses. Anthony -- https://mail.python.org/mailman/listinfo/python-list
How do I remove/unlink wildcarded files
Hi Everyone, I have a function I'm writing to delete wildcarded files in a directory. I tried this: def unlinkFiles(): os.remove(/home/anthony/backup/unix*) This doesn't seem to work because it's a wildcard filename. What is the proper way to delete files using wildcards? Thanks, Anthony -- Anthony Papillion Phone: 1.918.631.7331 XMPP Chat: cyp...@chat.cpunk.us Fingerprint: 65EF73EC 8B57F6B1 8C475BD4 426088AC FE21B251 iNum:+883510001190960 PGP Key: http://www.cajuntechie.org/p/my-pgp-key.html -- https://mail.python.org/mailman/listinfo/python-list
Read TLS cert serial number?
Is there a way to read the serial number of a TLS cert my app receives? Anthony Sent from my mobile device -- https://mail.python.org/mailman/listinfo/python-list
Why Python 3?
Hello Everyone, So I've been working with Python for a while and I'm starting to take on more and more serious projects with it. I've been reading a lot about Python 2 vs Python 3 and the community kind of seems split on which should be used. Some say 'Python 3 is the future, use it for everything now' and other say 'Python 3 is the future but you can't do everything in it now so use Python 2'. What is the general feel of /this/ community? I'm about to start a large scale Python project. Should it be done in 2 or 3? What are the benefits, aside from the 'it's the future' argument? Thanks, Anthony -- https://mail.python.org/mailman/listinfo/python-list
Re: How can I parse this correctly?
On Apr 5, 2014, at 23:03, Chris Angelico ros...@gmail.com wrote: On Sun, Apr 6, 2014 at 1:52 PM, Anthony Papillion papill...@gmail.com wrote: When I try to cast them like this: print int(row['YEAR']) I am told by the interpreter: Traceback (most recent call last): File analyze.py, line 14, in module print int(row['MONTH']) ValueError: invalid literal for int() with base 10: '' What am I doing wrong? Am I not understanding HOW to cast? An empty string isn't a valid Python integer, unlike in some other languages where it's taken as zero. Do you have data in some but not in others? Should all blank entries be interpreted as zero? (That's common with a lot of spreadsheets.) Make sure that's really what you want, and then just do this: print int(row['MONTH'] or 0) That'll set a default of zero, if (and only if) the MONTH string is blank. Many thanks! That's exactly what I was looking for. In this case, since I'm needing to create a valid date, I'm defaulting to 1. By the way, is there a reason you're using Python 2 rather than Python 3? For new projects, you ideally should be working with a more recent version of Python; that way, you won't have to edit your code later, when you find there's some newer feature that you want. The differences aren't huge, but the sooner you make the change, the less code you have to look at No particular reason at all. I've Bern dabbling in Python for the last bit and am just writing code based on the samples or examples I'm finding. What was the tipoff that this was not Python 3? Would there be a large difference in this code if it was Python 3? Anthony -- https://mail.python.org/mailman/listinfo/python-list
Re: How can I parse this correctly?
On Apr 5, 2014, at 23:21, Ben Finney ben+pyt...@benfinney.id.au wrote: Anthony Papillion papill...@gmail.com writes: for row in r: print row['YEAR'] This works fine. But, I am needing to do date addition/subtraction using datetime and so I need these dates as integers. I assume you mean you will be creating ‘datetime.date’ objects. Wh at will you set as the month and day? Right, I did mean datetime.date. As form month and day, I also have a column in my data for that. I'll be pulling it the same way I'm doing with year Alternatively, if you just want to do integer arithmetic on the year, you don't need the ‘datetime’ module at all. True. But I do actually need to some date based calculations. Basically I'm processing a large data set and calculating time intervals between entries When I try to cast them like this: Python doesn't have “cast”; instead, you request the creation of a new object by calling the type. Hmm, interesting. I need to think on that for a moment. I may well have completely misunderstood a major part of Python all this time. print int(row['YEAR']) What do you expect this to return when ‘row['YEAR']’ is ‘’ (empty string)? I expected a defaut value to be returned, perhaps 0. I see now from another response that this is not the case and so I've fixed it to read print int(row['YEAR'] or ) I am told by the interpreter: Traceback (most recent call last): File analyze.py, line 14, in module print int(row['MONTH']) ValueError: invalid literal for int() with base 10: '' What am I doing wrong? You've ignored the condition where your ‘row['YEAR']’ is the empty string. Python doesn't have an unambiguous integer represented by the empty string, so it refuses to guess. You'll need to handle that specially, and decide what value you want when that's the case. Thank you! I actually like the fact that it won't simply fill something in. It makes things more predictable and stable. Anthony -- https://mail.python.org/mailman/listinfo/python-list
How can I parse this correctly?
Hello Everyone, I'm working with historical earthquake data and I have a tab delimited file. I'm using the csv module with the \t delimiter to denote it's tab separated and it's working fine. I've set things up loike this: import csv f = open('earthquakes.tsv') r = csv.DictReader(f, delimiter='\t') for row in r: print row['YEAR'] This works fine. But, I am needing to do date addition/subtraction using datetime and so I need these dates as integers. When I try to cast them like this: print int(row['YEAR']) I am told by the interpreter: Traceback (most recent call last): File analyze.py, line 14, in module print int(row['MONTH']) ValueError: invalid literal for int() with base 10: '' What am I doing wrong? Am I not understanding HOW to cast? Thanks, Anthony -- https://mail.python.org/mailman/listinfo/python-list
How to parse JSON passed on the command line?
Hello Everyone, I'm writing a little helper script in Python that will access a JSON formatted argument from the shell when it's called. The parameter will look like this: {url:http://www.google.com} So, if my program is called getargfromcli.py the call will look like this: getargfromcli.py {url:http://www.google.com} In the case above, I assume my JSON string will be argv[1]. In fact, when I do print sys.argv[1] It works as expected and prints out the JSON string as expected like this: {url:http://www.google.com} Now, for the harder part. When I try to PARSE this JSON using this code: json_string = json.loads(sys.argv[1]) I get an error saying that No JSON object could be decoded. Even though this looks like valid JSON and was generated by a JSON generator. Can anyone tell me what I'm doing wrong? Basically, I want to eventually get the value of url into a string. Thanks! anthony -- https://mail.python.org/mailman/listinfo/python-list
Another question about JSON
Hello Again Everyone, I'm still working to get my head around JSON and I thought I'd done so until I ran into this bit of trouble. I'm trying to work with the CoinBase API. If I type this into my browser: https://coinbase.com/api/v1/prices/buy I get the following JSON returned {subtotal:{amount:128.00,currency:USD},fees:[{coinbase:{amount:1.28,currency:USD}},{bank:{amount:0.15,currency:USD}}],total:{amount:129.43,currency:USD},amount:129.43,currency:USD} So far, so good. Now, I want to simply print out that bit of JSON (just to know I've got it) and I try to use the following code: returnedJSON = json.loads('https://coinbase.com/api/v1/prices/buy') print returnedString And I get a traceback that says: No JSON object could be decoded. The specific traceback is: Traceback (most recent call last): File coinbase_bot.py, line 31, in module getCurrentBitcoinPrice() File coinbase_bot.py, line 28, in getCurrentBitcoinPrice returnedString = json.loads(BASE_API_URL + '/prices/buy') File /usr/lib/python2.7/json/__init__.py, line 326, in loads return _default_decoder.decode(s) File /usr/lib/python2.7/json/decoder.py, line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File /usr/lib/python2.7/json/decoder.py, line 384, in raw_decode raise ValueError(No JSON object could be decoded) ValueError: No JSON object could be decoded I'm very confused since the URL is obviously returned a JSON string. Can anyone help me figure this out? What am I doing wrong? Thanks in advance! Anthony -- Anthony Papillion XMPP/Jabber: cypherp...@patts.us OTR Fingerprint: 4F5CE6C07F5DCE4A2569B72606E5C00A21DA24FA SIP: 17772471...@callcentric.com PGP Key: 0xE1608145 -- https://mail.python.org/mailman/listinfo/python-list
Re: Another question about JSON
On 09/13/2013 08:24 AM, Peter Otten wrote: Anthony Papillion wrote: And I get a traceback that says: No JSON object could be decoded. The specific traceback is: Traceback (most recent call last): File coinbase_bot.py, line 31, in module getCurrentBitcoinPrice() File coinbase_bot.py, line 28, in getCurrentBitcoinPrice returnedString = json.loads(BASE_API_URL + '/prices/buy') File /usr/lib/python2.7/json/__init__.py, line 326, in loads return _default_decoder.decode(s) File /usr/lib/python2.7/json/decoder.py, line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File /usr/lib/python2.7/json/decoder.py, line 384, in raw_decode raise ValueError(No JSON object could be decoded) ValueError: No JSON object could be decoded So json.loads() expects its first argument to b valid json, no a URL. You have to retrieve the data using other means before you can deserialize it: data = urllib2.urlopen(...).read() returned_json = json.loads(data) Replacing ... with something that works is left as an exercise. (It seems that you have to use a Request object rather than a URL, and that the default Python-urllib/2.7 is not an acceptable user agent. Thank you Peter! That was all I needed. So here's the code I came up with that seems to work: req = urllib2.Request(BASE_URL + '/prices/buy') req.add_unredirected_header('User-Agent', USER_AGENT) resp = urllib2.urlopen(req).read() data - json.loads(resp) return data['amount'] Thank you for the help! Anthony -- Anthony Papillion XMPP/Jabber: cypherp...@patts.us OTR Fingerprint: 4F5CE6C07F5DCE4A2569B72606E5C00A21DA24FA SIP: 17772471...@callcentric.com PGP Key: 0xE1608145 -- https://mail.python.org/mailman/listinfo/python-list
Re: Can I trust downloading Python?
On 09/09/2013 04:41 AM, Steven D'Aprano wrote: On Mon, 09 Sep 2013 02:39:09 +1000, Chris Angelico wrote: On Mon, Sep 9, 2013 at 2:08 AM, Charles Hottel chot...@earthlink.net wrote: I think this article is relevant althought the code examples are not Python but C: http://cm.bell-labs.com/who/ken/trust.html That is quite true, and yet not truly helpful here :) It's like pointing out that we could be being fed false information, and then suggesting that The Matrix is technically possible. Once you start distrusting to that level, you become paranoid to a point that's inappropriate to all but the most critical situations. I'd accept and maybe even recommend that sort of paranoia if you're running a nuclear power station, or an automated weapon system capable of firing missiles that destroy the planet, or a bank that holds everyone's money. For the average Joe, there's no point panicking. Also: That hack works beautifully when there's precisely one C compiler. In today's world, there are many (well known ones like gcc, clang, MS Visual Studio (whatever the compiler from that is called), and a bunch of lesser-known ones as well), and it's pretty easy to just grab a different compiler and build. The chances that your code will be falsely compiled by TWO compilers would have to be infinitesimal, and you needn't stop at two. That logic is dubious. Compilers aren't compromised by chance, and we don't know the a priori probability of any specific compiler being compromised. That depends on the attacker, surely? We know, for example, that the NSA has compromised multiple brands of router, smart phone and similar. If they, or some other similar organisation with equivalent capabilities, were going to attack compilers in the same manner, they surely wouldn't stop at one. But (and this is stepping into *really* paranoid territory here. But maybe not beyond the realm of possibility) it would not be so hard to compromise compilers at the chip level. If the NSA were to strike an agreement with, say, Intel so that every time a compiler ran on the system, secret code was discreetly inserted into the binary, it would be nearly impossible to detect and a very elegant solution to a tough problem. -- https://mail.python.org/mailman/listinfo/python-list
How can I remove the first line of a multi-line string?
Hello Everyone, I have a multi-line string and I need to remove the very first line from it. How can I do that? I looked at StringIO but I can't seem to figure out how to properly use it to remove the first line. Basically, I want to toss the first line but keep everything else. Can anyone put me on the right path? I know it is probably easy but I'm still learning Python and don't have all the string functions down yet. Thanks, Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I remove the first line of a multi-line string? (SOLVED)
On 09/02/2013 11:12 AM, Chris “Kwpolska” Warrick wrote: On Mon, Sep 2, 2013 at 6:06 PM, Anthony Papillion papill...@gmail.com wrote: Hello Everyone, I have a multi-line string and I need to remove the very first line from it. How can I do that? I looked at StringIO but I can't seem to figure out how to properly use it to remove the first line. Basically, I want to toss the first line but keep everything else. Can anyone put me on the right path? I know it is probably easy but I'm still learning Python and don't have all the string functions down yet. Thanks, Anthony -- http://mail.python.org/mailman/listinfo/python-list Use split() and join() methods of strings, along with slicing. Like this: fullstring = foo bar baz sansfirstline = '\n'.join(fullstring.split('\n')[1:]) The last line does this: 1. fullstring.split('\n') turns it into a list of ['foo', 'bar', 'baz'] 2. the [1:] slice removes the first element, making it ['bar', 'baz'] 3. Finally, '\n'.join() turns the list into a string separated by newlines (bar baz) This, of course, worked like a charm. I really need to study the string methods. In the work I'm doing they are going to come in very handy. Thank you, Chris! Anthony -- http://mail.python.org/mailman/listinfo/python-list
How do I process this using Python?
Hello Everyone, I'm writing a processor for Bitmessage messages and I am needing to parse the following returned JSON string: {u'inboxMessages': [{u'fromAddress': u'BM-2DBYkhiBZCyrBa8J7gFRGrFRSGqtHgPtMvwQ', u'toAddress': u'BM-2DC7SCTj2gzgrGgMvUCARdrfrsgLyz3iMyN3', u'read': 0, u'msgid': u'36659a4453e12a085d8fbfeefc58da8fb23f38bfb0984c2983e0ddc31c776038', u'receivedTime': u'1377986524', u'message': u'dGVzdGluZyAxIDIgMw0KDQotLQ0KSm9obiBQZXJyeQ0KDQo=\n', u'encodingType': 2, u'subject': u'bWVzc2FnZSAx\n'}, {u'fromAddress': u'BM-2DBYkhiBZCyrBa8J7gNBrngtgttHgPtMvwQ', u'toAddress': u'BM-2DC7SCTj2gzgrGgMvUCARdCrfthyz3iMyN3', u'read': 0, u'msgid': u'2ebe10c788ed47c6c122e3b43ae6642cb15077536c7056ed5088ab2d339c4630', u'receivedTime': u'1377986557', u'message': u'VGhpcyBpcyB0aGUgbmV4dCB0ZXN0DQoNCi0tDQpKb2huIFBlcnJ5DQoNCg==\n', u'encodingType': 2, u'subject': u'dGVzdGluZyAzIDQgNQ==\n'}, {u'fromAddress': u'BM-2DBYkhithgyhyrBa8J7gNBrnSGqtHgPtMvwQ', u'toAddress': u'BM-2DC7SCTj2gzgrtgtgMvUCARdCogLyz3iMyN3', u'read': 0, u'msgid': u'91dffd421c898aab0ffc43a363869a580abec6fa851aa6cf7cefe98263f96c81', u'receivedTime': u'1377986599', u'message': u'VGhpcyBpcyB0aGUgM3JkIHRlc3QNCg0hjj0NCkpvaG4gUGVycnkNCg0K\n', u'encodingType': 2, u'subject': u'dGhpcyBpcyB0aGUgM3Jk\n'}]} I tried using the following code: data = json.loads(api.getAllInboxMessages) # This is the API call for messageSender in data['inboxMessages']['fromAddress'] print messageSender For some reason (probably obvious reasons) isn't working. I'm trying to loop through the JSON and return all of the fromAddress fields. Can anyone offer suggestions? Thanks, Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I process this using Python?
On 08/31/2013 06:48 PM, Chris Angelico wrote: On Sun, Sep 1, 2013 at 9:44 AM, Anthony Papillion papill...@gmail.com wrote: I'm writing a processor for Bitmessage messages and I am needing to parse the following returned JSON string: {u'inboxMessages': Does the JSON string really have those u prefixes and apostrophes? That's not valid JSON. You may be able to use ast.literal_eval() on it - I was able to with the example data - but not a JSON parser. Can you sort out your transmission end? ChrisA I think I remembered what the 'u' prefix is. It indicates that the data following is a unicode string. So could that be valid JSON data wrapped up in unicode? Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I process this using Python?
On 08/31/2013 07:32 PM, Cameron Simpson wrote: On 31Aug2013 19:19, Anthony Papillion papill...@gmail.com wrote: | On 08/31/2013 06:48 PM, Chris Angelico wrote: | On Sun, Sep 1, 2013 at 9:44 AM, Anthony Papillion papill...@gmail.com wrote: | I'm writing a processor for Bitmessage messages and I am needing to | parse the following returned JSON string: | | {u'inboxMessages': | | Does the JSON string really have those u prefixes and apostrophes? | That's not valid JSON. You may be able to use ast.literal_eval() on it | - I was able to with the example data - but not a JSON parser. Can you | sort out your transmission end? | | I think I remembered what the 'u' prefix is. It indicates that the data | following is a unicode string. So could that be valid JSON data wrapped | up in unicode? How sure are you that it is JSON? It looks to me like a message that might once have been JSON, but has already been passed through json.loads() for you. What does type(the_json) say? What does repr(the_json) say? Print both. I would guess it has already been parsed. Cheers, And you would be right! It's actually a dictionary! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I process this using Python? (SOLVED)
On 08/31/2013 07:32 PM, Chris Angelico wrote: On Sun, Sep 1, 2013 at 10:19 AM, Anthony Papillion papill...@gmail.com wrote: On 08/31/2013 06:48 PM, Chris Angelico wrote: On Sun, Sep 1, 2013 at 9:44 AM, Anthony Papillion papill...@gmail.com wrote: I'm writing a processor for Bitmessage messages and I am needing to parse the following returned JSON string: {u'inboxMessages': Does the JSON string really have those u prefixes and apostrophes? That's not valid JSON. You may be able to use ast.literal_eval() on it - I was able to with the example data - but not a JSON parser. Can you sort out your transmission end? ChrisA I think I remembered what the 'u' prefix is. It indicates that the data following is a unicode string. So could that be valid JSON data wrapped up in unicode? No; JSON already supports Unicode. What you may have is an incorrect JSON encoder that uses Python's repr() to shortcut its work - but it's wrong JSON. But bitmessage seems to be written in Python. Can you simply access the objects it's giving you, rather than going via text strings? ChrisA Once I looked at the data in a better structured way and saw it in the proper type it became clear. Here is my solution: data = json.loads(api.getAllInboxMessages()) for message in data['inboxmessages']: print message['fromAddress'] Yep, it was that simple. Thanks for the help guys! I appreciate how fast everyone responded. Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about crypto
On 08/18/2013 05:29 PM, Skip Montanaro wrote: When I run the code above, I am told that the IV must be 16 bytes long. I'm assuming that the IV (I know that means Initialization Vector) is either the key OR something else I can set. But I don't know how or what to do. Does this Stack Overflow thread help? It looks to me like you aren't defining an initialization vector at all. http://stackoverflow.com/questions/14716338/pycrypto-how-does-the-initialization-vector-work Completely missed that Stack Overflow discussion. Thanks, Skip! That does help! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about crypto
On 08/18/2013 05:52 PM, Roy Smith wrote: In article mailman.6.1376863028.19984.python-l...@python.org, Anthony Papillion papill...@gmail.com wrote: I've just started working with the Crypto library and I've already run into a wall even though I'm following a tutorial. Basically, I'm trying to encrypt a string using AES in CBC mode. Here is the code: from Crypto import AES You don't say exactly what module you're using. I'm assuming https://www.dlitz.net/software/pycrypto/api/current/, yes? snip Thank you, Roy, this was very helpful. You're right, I was confusing key size with the IV and I was tying the two together in an inappropriate (wrong) way. Thanks again! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Question about crypto
I've just started working with the Crypto library and I've already run into a wall even though I'm following a tutorial. Basically, I'm trying to encrypt a string using AES in CBC mode. Here is the code: from Crypto import AES import hashlib text_to_encrypt = 'This is a super secret encrypted message, yo!' key = '0123456789abcdef' mode = AES.MODE_CBC encryptor = AES.new(key, mode) ciphertext = encryptor.encrypt(text) When I run the code above, I am told that the IV must be 16 bytes long. I'm assuming that the IV (I know that means Initialization Vector) is either the key OR something else I can set. But I don't know how or what to do. Does anyone see what is wrong with the code above and could suggest ways to make it work? I've spent the last 45 minutes googling around and nothing comes up specific to my problem. Thanks, Anthony -- http://mail.python.org/mailman/listinfo/python-list
Question about function failing with large number
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 So I'm using the function below to test a large (617 digit) number for primality. For some reason, when I execute the code, I get an error telling me: OverflowError: long int too large to convert to float The error is being thrown on this line: for x in range(3, int(n**0.5)+1, 2): The odd thing is that the error is not thrown every single time. I can run the function a few times, it will generate a large number (always the same length) and run it through the function. After I do this a few times, it fails with the error. I might get the error on the next few runs but then, all of a sudden, it functions again. Any ideas? The entire program, including the method, is below. #!/usr/bin/env python from random import getrandbits bits = 2048 # Test if the number is a prime def isprime(n): # make sure n is a positive integer n = abs(int(n)) # 0 and 1 are not primes if n 2: return False # 2 is the only even prime number if n == 2: return True # all other even numbers are not primes if not n 1: return False # range starts with 3 and only needs to go up the squareroot of n # for all odd numbers for x in range(3, int(n**0.5)+1, 2): if n % x == 0: return False return True a = getrandbits(bits) print \nGenerated Number: , a, \n print Number of digits: , len(str(a)) isNumberPrime = isprime(a) if isNumberPrime == True: print \nThis number is a prime.\n else: print \nThis number is not a prime.\n Thanks! Anthony - -- Anthony Papillion Phone: 1.918.533.9699 SIP: 17772098...@in.callcentric.com XMPP:cypherp...@patts.us www.cajuntechie.org -BEGIN PGP SIGNATURE- iQIcBAEBCgAGBQJSCiKNAAoJEKCKfnPhYIFFn7gP/A8CHOyTv71J/uVpMVYRcDRp KRwbL9A1gkzUpycQibN3Q90FwY6nsGGPCeOkZByfYZnMKQH0o4Kd7QQf0hEOkhzO BLiQjbkjzuUq7usE5TIqjTi0pJ6J7DcRm6U77yhAWrVt60MpfOucojLzX8ZolTD6 7Ha1gJ+9uEcwjosx1ynjVt7MQ/uGZwM7xS6WNfOpOwIYnoT5zBUzlKbw1HqSGYLu 6cWmAFTnnnXv6qymbGTxdZf0dxciODXy5xIMp5CzG6zIeHIOvjG03AbcY/+nI5FI b9fKqjbblE/Npnh9GPXOLpI+I05VZMoO1b0AJSlU+Iq1liZAZOA4s2kf7XCrSb7Y 8Zn6qMPMTuNBPZpRJykTJSrA8s+4RxA0BWoq9rnTNXJPVR6imt6USOtwY4UssPxw HIUrbSmfAEF9+/g08mcKHTVFstMyQCuAbUGx+LxoxkySnwZkfcwTRQ2vuoBDd7XP 92IJlkAdwepEa748P6NHNkSN4+OV3zAeTczHkzD0OL2KAeCuPY5tlqsI0MAngKOu TIZrG+w1rvkz1gU3TBILLySuQTk/ioHNoVAH46bvp6ARRJiHJ4Ub61NoyooMCOgX Lg+XtmcYz9VdUzdayg5uwNQAb/2/DboAyvmuuRDrA2Lzndv1JO3ye222/WCI9e7V aB1ghvNnNMtrOWA0ZVQX =BZUP -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
OK, I lied, I do have another question...
Hi Everyone, So I've used Glade to build a simple UI and I'm loading it with gtkBuilder. The UI loads fine but, for some reason, none of my signals are being connected. For example, in Glade, I said when the button called btnExit was clicked, execute the btnExit_clicked method. Then, in my App() class definition, I defined btnExit_clicked(self, widget) and simply added the gtk.main_quit() statement (to exit). But when I start my app, I am told that the btnExit_clicked() method isn't defined. This happens for every single signal I define. I'm assuming I'm simply putting something in the wrong place so can anyone have a look at this and tell me what that might be? It looks almost identical to examples I've seen on the net. Thanks! CODE: class App: def __init__(self): builder = gtk.Builder() builder.add_from_file('bcbackup.ui') builder.connect_signals({on_window_destroy : gtk.main_quit, on_btnExit_clicked : btnExit_clicked}) self.window = builder.get_object(winMain) self.window.show() def btnSaveInformation_clicked(self, widget): pass def btnExit_clicked(self, widget): gtk.main_quit() if __name__ == __main__: myApp = App() gtk.main() END CODE -- http://mail.python.org/mailman/listinfo/python-list
Re: Wgy isn't there a good RAD Gui tool fo python
As someone who was a Visual Studio user for many years, I felt much the same way you do when I made the jump to Python on Linux last year. But then I discovered Glade and am quite satisfied. Glades UI design paradigm is a little different than that of VS but it's not so hard that you couldn't learn it in a week. It's very usable, pretty easy to learn, and doesn't cost you a penny. If you've not already, I recommend you check out Glade. I think it's probably what you're looking for. Anthony On 7/10/11, Ivan Kljaic iklj...@gmail.com wrote: Ok Guys. I know that most of us have been expiriencing the need for a nice Gui builder tool for RAD and most of us have been googling for it a lot of times. But seriously. Why is the not even one single RAD tool for Python. I mean what happened to boa constructor that it stopped developing. I simply do not see any reasons why there isn't anything. Please help me understand it. Any insights? -- http://mail.python.org/mailman/listinfo/python-list -- Anthony Papillion Advanced Data Concepts Get real about your software/web development and IT Services Phone: (918) 919-4624 Does your business need to reduce its phone bill? I can help! Email me and ask me how! -- http://mail.python.org/mailman/listinfo/python-list
How to get or set the text of a textfield?
Hi Everyone, So I've built a UI with Glade and have loaded it using the standard Python code. In my UI, I have a textfield called txtUsername. How do I get and set the text in this field from my Python code? Thanks! Anthony -- Anthony Papillion Advanced Data Concepts Get real about your software/web development and IT Services Phone: (918) 919-4624 Does your business need to reduce its phone bill? I can help! Email me and ask me how! -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get or set the text of a textfield? - SOLVED
I don't know anything about Glade, so I can't answer your question definitively. However, as a general rule, you can use the dir() builtin function to see what methods are defined by an object. Hi John, Thanks for the input and it looks like it's pretty simple. Basically, I can access the properties of objects like: self.objectname.property_or_method() So, to solve my question, I'd just use: self.txtUsername.set_text('Whatever I want') or enteredText = self.txtUsername.get_text() Pretty simple and this actually solves ALL of my Glade problems. I'm excited. Thanks for the direction! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Why are my signals being ignored?
Hello Everyone, So I figured out the last problem about why I couldn't load my UI files but now I've got something that has be totally stumped. I've worked on it most of the day yesterday, Google'd it, and fought with it today and I'm admitting defeat and coming to the group with hat in hand asking for help. For some reason, in the code below, my signals are being completely ignored. For example, you'll notice that I connected the 'btnExit' to the method called 'clickedButton()' but, for some reason, when the button is clicked, the method is never called. I've been following tutorials and this seems to be the proper way to wire signals yet mine simply don't work. Would anyone be so kind as to look over the following code and give me a bit of advice (or direction) as to what I might be doing wrong? Thanks! Anthony Code: #!/usr/bin/env python import sys try: import pygtk pygtk.require(2.0) except: print Error. PYGTK could not be loaded. sys.exit(1) try: import gtk import gtk.glade except: print GTK not present or not loaded. sys,exit(1) class TestClass(object): def __init__(self): self.uiFile = MainWindow.glade self.wTree = gtk.Builder() self.wTree.add_from_file(self.uiFile) self.window = self.wTree.get_object(winMain) if self.window: self.window.connect(destroy, gtk.main_quit) dic = { on_btnExit_clicked : self.clickButton, on_winMain_destroy : gtk.main_quit } self.wTree.connect_signals(dic) self.window.show() else: print Could not load window sys.exit(1) def clickButton(self, widget): print You clicked exit! def exit(self, widget): gtk.main_quit() def update_file_selection(self, widget, data=None): selected_filename = FileChooser.get_filename() print selected_filename if __name__ == __main__: Tester = TestClass() gtk.main() -- http://mail.python.org/mailman/listinfo/python-list
Simple question about loading a .glade UI file
Hi Everyone, So I'm tackling designing a non-CLI program using Glade. I went through some tutorials and it seems like I'm doing things right but I'm my UI won't load. Python keeps griping about could not create glade XML object. I have a .glade file called MainWindow.glade and my main window is called (predictably) winMain. Here is the code I'm using to load it: #!/usr/bin/env python import sys try: import pygtk pygtk.require(2.0) except: pass try: import gtk import gtk.glade except: print GTK could not be loaded. sys.exit(1) class GMB: def __init__(self): self.gladefile = MainWindow.glade self.wTree = gtk.glade.XML(self.gladefile) self.wTree.signal_autoconnect(self) self.window = self.wTree.get_widget(winMain) if(self.window): self.window.connect(destroy, gtk.main_quit) def on_winMain_delete(self, widget, dummy): gtk.main_quit() if __name__ == __main__: myGui = GMB() gtk.main() Is there any reason why I'd be getting this error from the code above? Both the UI file and the source code file are in the same directory. Thanks! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: New member intro and question
Just wanted to thank you guys for taking the time to respond. Looks like my 'limited resources' aren't so limited after all! Cheers, Anthony -- http://mail.python.org/mailman/listinfo/python-list
New member intro and question
Hi Everyone, gush I'm a new list member from the United States. Long time programmer, fairly new to Python and absolutely loving it so far! I'm 36, live in Oklahoma, and own a small Linux software development and consulting firm. Python has made my life a *lot* easier and, the more I learn, the easier it gets. Simply blown away. /gush Now, for my question: I'm taking on a project that will run on plug computers and I'm thinking about using Python to do it. It seems like a really attractive option over C/C++ and I think it would cut down the dev time immensely. I know a scaled down version of Debian can run on the computer but I'm wondering about Python. Has anyone ever used Python to develop for extremely limited resource computers like this? Specifically, I'm going to be using the DreamPlug (http://www.geek.com/articles/gadgets/dreamplug-puts-a-1-2ghz-arm-pc-in-a-power-outlet-2011022/) which isn't too shabby but I wonder if it will work. Thanks! Anthony Papillion -- http://mail.python.org/mailman/listinfo/python-list
Redirecting STDOUT to a Python Variable
I'm writing an application that uses the Google Storage Python library. When an error occurs, the error is printed on the terminal. What I need to do is intercept that text into a variable so I can run a re.search() against it and find out what's going on. I thought doing a output_text = method_name(parameters) would stuff the output in the output_text variable but it doesn't. How can I accomplish this? -- http://mail.python.org/mailman/listinfo/python-list
TkInter bind() event is not firing event trigger
So I want to execute some code when the user double clicks an item in a ListBox. The documentation says I should use the listbox.bind() method, specifying the Double-l event to detect the double left mouse button click. My code is this: gsItems = Listbox(root, width=76, height=30, selectmode=browse, yscroll=scrollBar.set) gsItems.bind('Double-l', openandDisplayFolder) gsItems.pack() So the first line configures the Listbox, second line SHOULD set up the event, and third line, of course, adds the Listbox to the UI. The problem is that the openandDisplayFolder function is never executed. The function is VERY simple for now while I learn the way to do it: def openandDisplayFolder(event): tkMessageBox.showinfo(Event Fired, An item has been double clicked!) I've also removed the (event) parameter just in case and tried it and it makes no difference. What am I doing wrong here? Thanks! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: tkInter Listbox question
Thank you, RantingRick and EB303. Much appreciated and it looks like it works fine now. Still learning but I am amazed every single day how simple Python is! Thanks Again, Anthony Papillion -- http://mail.python.org/mailman/listinfo/python-list
tkInter Listbox question
So I'm trying to add a Listbox to my window. I want it to be the width of my window and the height of my window. I'm using the following code ('root' is my toplevel window): gsItems = Listbox(root, width=root.winfo_width(), height=root.winfo_height()) gsItems.pack() While you would think this code would set the height and width of gsItems to the height and width of root, it doesn't. Instead it puts a little tiny listbox in the middle of the form. I've been Googling for almost an hour. Can anyone help me figure this out? Point me in the right direction? Thanks! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Python on Android Mobile?
I know Python is growing in popularity and some of Palms devices already let you run Python apps in a VM environment. I'm wondering if anyone knows (or can make an educated guess) if there are any plans for Python to come to the Android environment? I'm not talking backend stuff here but full front and center like full GTK or WX development for the devices? Any thoughts? -- http://mail.python.org/mailman/listinfo/python-list
Re: Community (A Modest Proposal)
Why was the reaction so negative? Well i will admit some fault in the fact that i trashed Ruby pretty bad. I felt everything i said was true IMO then as is now (mostly). People should have a right to opinions. However since i was such an unknown and you could say a newbie, was this reaction warranted? I think not, and it speaks volumes to the negative attitudes within this community. While I'm not new to software development in other languages, I'm completely new to Python and the Python community. I've only been here about a week and have asked some pretty elementary questions during that time only to be greeted respectfully and offered help. From reading the posts on this group, it seems like the Python community is much like any other programming (or even just volunteer community): they're helpful if you show you're willing to do the work yourself and if you show you've at least tried to solve the problem yourself to a degree (even if you've failed). Volunteer communities have little patience for the 'do it for me' mindset as *everyone* is busy with jobs, life, and their own pet projects. Overall, I couldn't disagree with you more. I find most communities (and the c.l.p community in particular) *very* accessible and very helpful. On the other hand, I *could* see how your post could scare off newbies from jumping in for fear of being 'attacked' as you say you were. IMHO, your posts serves no purpose but to hurt the community and scare away newbies. Anthony Papillion -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on Android Mobile?
Thank you gentleman for your input. I'm starting to look at Python/GTK for desktop development and was hoping there might also be something for Android. Oh well, like Simon said (pardon the pun), it is open source so... :-) Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the difference?
Thank you Emile and Thomas! I appreciate the help. MUCH clearer now. -- http://mail.python.org/mailman/listinfo/python-list
What's the difference?
Someone helped me with some code yesterday and I'm trying to understand it. The way they wrote it was subjects = (info[2] for info in items) Perhaps I'm not truly understanding what this does. Does this do anything different than if I wrote for info[2] in items subject = info[2] Thanks! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about NNTPLib
I just had a quick look at the documentation. It looks like you should re-read it.http://docs.python.org/py3k/library/nntplib.html#nntplib.NNTP.xhdr snip Thank you for the help Thomas. I did reread the doc and I see what you mean. I think this will work now. Much thanks for the help! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Another nntplib Question
Hello Everyone, Thanks to help from this group, my statistical project is going very well and I'm learning a LOT about Python as I go. I'm absolutely falling in love with this language and I'm now thinking about using it for nearly all my projects. I've run into another snag with nntplib I'm hoping someone can help me with. I'm trying to get a list of newsgroups from the server. The documentation for the list() method tells me it returns a response (string) and a list (tuple). The list tuple contains the following: groupname, last, first, flag. So, thinking I could access the group name in that list like this ThisGroup = groupname[1]. Now, along those lines, I am wanting to retrieve some information about each group in the list so I thought I could do this: resp, groupinfo = server.list() group = (info[1] for info in groupinfo) resp, count, first, last, name = server.group(group) But Python throws a TypeError and tells me I can't concatenate str and generator objects'. What am I doing wrong? I've been banging my head on this for a few hours and simply can't get it right. I've even googled for an example and couldn't find one that showed how to deal with this. Can anyone help? Thanks in advance! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: Another nntplib Question
Thomas, You have been my savior on this journey twice now and I appreciate it. What you did totally makes sense (and I had forgotten the list was zero based) and I'm going to try it out right now. Thank you SO much for your patience. I'm coming from a near pure .NET and PHP background so I'm still running into little 'gotchas' with Python. On my way though, I hope. lol Thanks again! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Question about NNTPLib
I'm new to NNTPLib (and Python) and I'm experiencing some behavior I can't understand. I'm writing a program to analyze newsgroup subject which will then produce statistics on topics discussed. For my example, I'm using this group (comp.lang.python) and trying to simply print out all of the subjects listed in the group. This is the code I'm using: resp, count, first, last, name = server.group('comp.lang.python') resp, items = server.xover(first, last) for subject in items: resp, subject = server.xhdr('subject', first, last) print subject While the loop will indeed LOOP through all of the items, the print statement generates unprintable character (they look like [] in the terminal window. What am I doing wrong? I've looked at the doc and it looks like this is how I'd call it. Am I missing something? Thanks! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about NNTPLib
Hi Tim, Tried both and neither works. While I really believe it's simply the wrong code, I'm wondering if my news server might be throwing something invalid into the header or not conforming to RFC standards. Thanks for taking a shot at this anyway though. Anyone have any other thoughts on why this isn't working? -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing modules
On Jun 6, 10:16 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: Anthony Papillion papill...@gmail.com writes: import os os.path.append('$HOME/gsutils/boto') thinking I could then successfully do the import boto statement. Nope. You'll need to give the literal path. Substitution of environment variables isn't performed implicitly in strings. -- \ “When we pray to God we must be seeking nothing — nothing.” | `\ —Saint Francis of Assisi | _o__) | Ben Finney Hi Ben, Thanks for the help! I'd misread the thread and thanked Chris while ignoring you. Much thanks to you for the help. Worked like a charm. -- http://mail.python.org/mailman/listinfo/python-list
Importing modules
Hello Everyone, I'm brand new to Python and have been finding it really easy to get into. But I've run into my very first problem that I'm hoping someone here might be able to help me with. I'm working with the Google Storage API and all of their Python library is under a directory called $HOME/gsutils/boto To begin my Python script, I'm support to import boto but that doesn't work because boto isn't in my search path (or my PYTHONPATH). So I tried this: import os os.path.append('$HOME/gsutils/boto') thinking I could then successfully do the import boto statement. Nope. Can anyone give me some direction on the correct way to import modules? Thanks! Anthony -- http://mail.python.org/mailman/listinfo/python-list
Re: Importing modules
On Jun 6, 10:33 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Jun 6, 2010 at 8:16 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: Anthony Papillion papill...@gmail.com writes: import os os.path.append('$HOME/gsutils/boto') thinking I could then successfully do the import boto statement. Nope. You'll need to give the literal path. Substitution of environment variables isn't performed implicitly in strings. Also, that should be sys.path.append(); os.path is an unrelated module that has no `append` function. You'll need to import sys instead of os obviously. Cheers, Chris --http://blog.rebertia.com Hi Chris, Thanks for saving me (again). I appreciate the help. While the os.path.append() was a typo (I really had sys.path.append()), the substitution was what was killing me. Thanks for the help! I owe you a beer. Anthon -- http://mail.python.org/mailman/listinfo/python-list