Re: Goto (Posting On Python-List Prohibited)
(Posting On Python-List Prohibited) why ? -- https://mail.python.org/mailman/listinfo/python-list
Re: Surprised by the command "del"
On Sat, 1 Mar 2008 21:05:41 +0100, "K Viltersten" <[EMAIL PROTECTED]> wrote: >I'm reading the docs and at 5.2 the del >statement is discussed. At first, i thought >i've found a typo but as i tried that >myself, it turns it actually does work so. > > a = ["alpha", "beta", "gamma"] > del a[2:2] > a > >Now, i expected the result to be that the >"beta" element has been removed. Obviously, >Python thinks otherwise. Why?! > >Elaboration: >I wonder why such an unintuitive effect has >been implemented. I'm sure it's for a very >good reason not clear to me due to my >ignorance. Alternatively - my expectations >are not so intuitive as i think. :) I think it should say del a[1:2] then it works -- http://mail.python.org/mailman/listinfo/python-list
List question
Hello, I am learning python and dont quuite understand why is this happening could someone explain? alist = [] blist = [ 'one','two','one and two','one and four','five','one two'] for f in blist: if 'one' and 'two' in f: alist.append(f) for i in alist: print i two one and two one two why is it printing the first "two"? tia -- http://mail.python.org/mailman/listinfo/python-list
My direct client Hiring and interviewing going on Live today.
Hi, My direct client Hiring and interviewing going on Live today. I am having some very good direct client openings currently. I can get the consultant interviewed within 24 business hours. Please drop me an email to get all my direct client openings. I will reply to only those emails which are delivered to [email protected]. Thanks and Regards, Yagnesh -- http://mail.python.org/mailman/listinfo/python-list
My direct client Hiring and interviewing going on Live today.
Hi, My direct client Hiring and interviewing going on Live today. I am having some very good direct client openings currently. I can get the consultant interviewed within 24 business hours. Please drop me an email to get all my direct client openings. I will reply to only those emails which are delivered to [email protected]. Thanks and Regards, Yagnesh -- http://mail.python.org/mailman/listinfo/python-list
Garbage collection of recursive inner function
Hi, I encountered garbage collection behaviour that I didn't expect when using a recursive function inside another function: the definition of the inner function seems to contain a circular reference, which means it is only collected by the mark-and-sweep collector, not by reference counting. Here is some code that demonstrates it: === def outer(): def inner(n): if n == 0: return 1 else: return n * inner(n - 1) return 42 import gc gc.set_debug(gc.DEBUG_SAVEALL) print outer() gc.collect() print gc.garbage === Output when executed: $ python internal_func_gc.py 42 [, (,), ] Note that the inner function is not called at all, it is only defined. If the inner function is moved outside the scope of the outer function, gc.garbage will be empty. If the inner function is inside but not recursive, gc.garbage will also be empty. If the outer function is called twice, there will be twice as many objects in gc.garbage. Is this expected behaviour? Collecting an object when its refcount reaches zero is preferable to collecting it with mark-and-sweep, but maybe there is a reason that a circular reference must exist in this situation. I want to check that first so I don't report a bug for something that is not a bug. Bye, Maarten -- http://mail.python.org/mailman/listinfo/python-list
Re: Garbage collection of recursive inner function
On Aug 5, 5:23 am, Terry Reedy <[EMAIL PROTECTED]> wrote: > To understand this, it helps to realize that Python functions are not, > in themselves, recursive. Recursiveness at any time is a property of a > function in an environment, which latter can change. More specifically, > a function call is recursive if the expression indicating the function > to call happens to indicate the function containing the call at the time > of evaluation just before the evaluation of the argument expressions. I didn't realize that the function looks up itself in the outer environment when it makes the recursive call, instead of at definition time. > Adding 'inner = None' at the end of an outer function will break the > cycle and with CPython, all will be collected when outer exits. I think I'll use that for inner functions that do need to access the outer environment, but do not need to live longer than the call to the outer function. > Not a bug, but an educational example and possibly useful to someone > running on CPython with gc turned off and making lots of calls to > functions with inner functions with recursive references. I learned a > bit answering this. That describes our application: in some cases, we have several gigabytes of small objects, in which case mark-and-sweep garbage collection takes quite a long time, especially if some of the objects have been pushed into the swap. I have broken all cycles in our own data structures a while ago, but got an unexpected memory leak because of these cyclic references from inner functions. Thanks for your clear explanation! Bye, Maarten -- http://mail.python.org/mailman/listinfo/python-list
Re: Make Money Using Paypal Get Paid Instantly
> Interesting. What is being suggested here is against Paypal's > acceptable usage policy. Consult with a real person who has been > successful before you jump into a scam like this and above all, make > sure that person is going to be there to support you the whole way > whether you just need to ask a question from time to time or need a > great deal of help. > > http://workfromhomereviews.org/ * * * Do yourself a favor today! * * * Give yourself every advantage you deserve! * * * http://workfromhomereviews.org/stealth-money-maker.html * * * Make it a great one! -- http://mail.python.org/mailman/listinfo/python-list
Getting errors from Imaplib
Hi,
first poster here. I still consider myself pretty much a Python newbie.
Let's say I have the following very simple Python code:
import imaplib
host = 'imap.gmail.com'
try:
imap_connection = imaplib.IMAP4(host)
print('success')
except imaplib.IMAP4.error:
print('authentication failed')
Now, Gmail doesn't like non-ssl connections. In this case I only want to return
an error. This worked for Pyhton 2.7 but in Python 3.4 I only get a traceback
(see below). The line print('authentication failed') is not executed at all.
How do I capture the error for using the print function?
Mac OS 10.10. Python 3.4.1. The script is part of a larger one that is talking
to my Xojo application.
Connected to pydev debugger (build 135.1057)
Traceback (most recent call last):
File "/Applications/Develop/PyCharm CE.app/helpers/pydev/pydevd.py", line
1733, in
debugger.run(setup['file'], None, None)
File "/Applications/Develop/PyCharm CE.app/helpers/pydev/pydevd.py", line
1226, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/Develop/PyCharm CE.app/helpers/pydev/_pydev_execfile.py",
line 38, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc) #execute the script
File "/Users/beatrixwillius/Documents/ Datei/Development/Mail
Archiver/Projects/MainClasses Projects/imap/test/test.py", line 6, in
imap_connection = imaplib.IMAP4(host)
File
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imaplib.py",
line 181, in __init__
self.open(host, port)
File
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imaplib.py",
line 257, in open
self.sock = self._create_socket()
File
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/imaplib.py",
line 247, in _create_socket
return socket.create_connection((self.host, self.port))
File
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socket.py",
line 509, in create_connection
raise err
File
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socket.py",
line 500, in create_connection
sock.connect(sa)
OSError: [Errno 65] No route to host
Mit freundlichen Grüßen/Regards
Trixi Willius
http://www.mothsoftware.com
Mail Archiver X: The email archiving solution for professionals
--
https://mail.python.org/mailman/listinfo/python-list
Re: Getting errors from Imaplib
Hi Chris,
no, pinging Yahoo doesn't work. But this is an additional problem - perhaps I
tested too often. This is one of my accounts for Imap testing and I only copied
the value from Mail.
For getting the error back this doesn't really matter.
> import imaplib
>
> host = 'imap.mail.yahoo.com'
> try:
> imap_connection = imaplib.IMAP4(host)
> print('success')
> except imaplib.IMAP4.error:
> print('authentication failed')
> On 30.11.2014, at 13:02, Chris Angelico wrote:
>
> You're getting an error before it even gets as far as authenticating -
> there's a network-level issue here. Are you able to ping that host?
> Something's not connected.
Mit freundlichen Grüßen/Regards
Trixi Willius
http://www.mothsoftware.com
Mail Archiver X: The email archiving solution for professionals
--
https://mail.python.org/mailman/listinfo/python-list
Re: Getting errors from Imaplib
On 30.11.2014, at 21:11, Chris Angelico wrote: > > 2) Network failures and auth problems should be dealt with the same > way. Change one line of code: > except (imaplib.IMAP4.error, OSError): > > Now it'll cope with OSError the same way it copes with IMAP errors. > > Does that answer your question? Thanks! That solves my problem. Mit freundlichen Grüßen/Regards Trixi Willius http://www.mothsoftware.com Mail Archiver X: The email archiving solution for professionals -- https://mail.python.org/mailman/listinfo/python-list
Getting errors from Imaplib - reloaded
Hi,
thanks to your help I can get traceback errors for the imaplib. But what about
accessing direct imap errors? In the following part of my script I can't select
the not-deleted mails for some reason. But how do I access the error? The
debugger goes to the exception line but OSError.strerror doesn't have anything.
And print(imaplib.IMAP4.error) only gives me as
result.
import imaplib
host = "xxx"
username = "bla"
password = "blub"
mailbox = "\"Ablage.Kunden\""
imap_connection = imaplib.IMAP4(host)
result, data = imap_connection.login(username, password)
result, data = imap_connection.select(mailbox, True)
try:
result, messages_data = imap_connection.search(None, "NOT DELETED")
print('okay')
except (imaplib.IMAP4.error, OSError):
#print(OSError.strerror)
#print(imaplib.IMAP4.error)
print('xxxerrorxxx: select mails exception')
imap_connection.logout()
Mit freundlichen Grüßen/Regards
Trixi Willius
http://www.mothsoftware.com
Mail Archiver X: The email archiving solution for professionals
--
https://mail.python.org/mailman/listinfo/python-list
Re: Tabs versus Spaces in Source Code
> Simply put, tabs is proper, and spaces are improper. > Why? This may seem > ridiculously simple given the de facto ball of confusion: the semantics > of tabs is what indenting is about, while, using spaces to align code > is a hack. The reality of programming practice trumps original intent of tab characters. The tab character and space character are pliable in that if their use changes their semantics change. > ... and the solution is to advance > the sciences such that your source code in some way > embed such information. If/when time comes where such info is embeded perhaps then tabs will be OK. --- I use spaces because of the many sources I've opened I have many times sighed on opening tabed ones and never done so opening spaced ones. I don't get mad, but sighing is a clear indicator of negativity. Anyway, the more code I write and read the less indentation matters to me. My brain can now parse akward source correctly far bettter than it did a few years ago. All the best, Opalinski [EMAIL PROTECTED] http://www.geocities.com/opalpaweb/ -- http://mail.python.org/mailman/listinfo/python-list
