import inspect error
I have following errors running on Ubuntu 18, any insight how to fix it? Thank you. Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import inspect Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/inspect.py", line 42, in from collections import namedtuple File "/usr/lib/python2.7/collections.py", line 22, in from keyword import iskeyword as _iskeyword File "keyword.py", line 3, in from inspect import currentframe, getframeinfo ImportError: cannot import name currentframe -- https://mail.python.org/mailman/listinfo/python-list
Re: import inspect error
On Mon, Sep 17, 2018 at 6:06 PM, nobody wrote: > I have following errors running on Ubuntu 18, any insight how to fix it? > Thank you. > > Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) > [GCC 7.3.0] on linux2 > Type "help", "copyright", "credits" or "license" for more information. import inspect > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.7/inspect.py", line 42, in > from collections import namedtuple > File "/usr/lib/python2.7/collections.py", line 22, in > from keyword import iskeyword as _iskeyword > File "keyword.py", line 3, in > from inspect import currentframe, getframeinfo > ImportError: cannot import name currentframe You've made a file called keyword.py, which is shadowing the standard library module of that name. Rename or delete that file, and you should be able to use the original again. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: import inspect error
You appear to have a local file named keyword.py which is hiding a python installation file of the same name. Gary Herron On 09/17/2018 01:06 AM, [email protected] wrote: I have following errors running on Ubuntu 18, any insight how to fix it? Thank you. Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. import inspect Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/inspect.py", line 42, in from collections import namedtuple File "/usr/lib/python2.7/collections.py", line 22, in from keyword import iskeyword as _iskeyword File "keyword.py", line 3, in from inspect import currentframe, getframeinfo ImportError: cannot import name currentframe -- Dr. Gary Herron Professor of Computer Science DigiPen Institute of Technology (425) 895-4418 -- https://mail.python.org/mailman/listinfo/python-list
Re: Add header at top with email.message
Jason Friedman writes:
> I suppose you already figured out that you can call __delitem__() to
> clear the headers and add them back in whatever order you like.
Well, this would mean saving all headers, deleting all, inserting my
own, and adding the saved original headers again. Seems complicated.
> I'm interested in learning more about your use case. Do you have a
> third party with fixed logic that requires the headers in a particular
> order?
Yes, RFC 5321, section 4.4[0] :)
> When an SMTP server receives a message for delivery or further
> processing, it MUST insert trace ("time stamp" or "Received")
> information at the beginning of the message content, as discussed in
> Section 4.1.1.4.
To trace the path a message went, those headers do need to be in a
particular order, or else they won’t make any sense.
[0]: https://tools.ietf.org/html/rfc5321#section-4.4
--
https://mail.python.org/mailman/listinfo/python-list
Explicit vararg values
I started to send this to python-ideas, but I'm having second thoughts.
Does tihs have merit?
---
I stumble on this a lot, and I see it in many python libraries:
def f(*args, **kwargs):
...
f(*[list comprehension])
f(**mydict)
It always seems a shame to carefully build up an object in order to explode
it, just to pack it into a near-identical object.
Today I was fiddling with the new python3.7 inspect.signature functionality
when I ran into this case:
def f(**kwargs): pass
sig = inspect.signature(f)
print(sig.bind(a=1, b=2))
The output is "". I found this a
bit humorous since anyone attempting to bind values in this way, using
f(kwargs={'a': 1, 'b': 2}) will be sorely dissappointed. I also wondered
why BoundArguments didn't print '**kwargs' since that's the __str__ of that
parameter object.
The syntax I'm proposing is:
f(**kwargs={'a': 1, 'b': 2})
as a synonym of f(a=1, b=2) when an appropriate dictionary is already on
hand.
---
I can argue for this another way as well.
1)
When both caller and callee have a known number of values to pass/receive,
that's the usual syntax:
def f(x) and f(1)
2)
When the caller has a fixed set of values, but the callee wants to handle a
variable number: def f(*args) and f(1)
3)
Caller has a variable number of arguments (varargs) but the call-ee is
fixed, that's the splat operator: def f(x) and f(*args)
4)
When case 1 and 3 cross paths, and we have a vararg in both the caller and
callee, right now we're forced to splat both sides: def f(*args) and
f(*args), but I'd like the option of opting-in to passing along my list
as-is with no splat or collection operations involved: def f(*args) and
f(*args=args)
Currently the pattern to handle case 4 neatly is to define two versions of
a vararg function:
def f(*arg, **kwargs):
return _f(args, kwargs)
return _f(args, kwargs):
...
Such that when internal calllers hit case 4, there's a simple and efficient
way forward -- use the internal de-vararg'd definition of f. External
callers have no such option though, without breaking protected api
convention.
My proposal would simplify this implementation as well as allowing users to
make use of a similar calling convention that was only provided privately
before.
Examples:
log(*args) and _log(args) in logging.Logger
format and vformat of strings.Formatter
--
https://mail.python.org/mailman/listinfo/python-list
Python in endless loop
Dear Python, Hello. This is an email concerning about my Python program(3.7.0). It keeps printing out stuff that’s too fast to read. If I try to write code, it just keeps on going. I have tried Ctrl+C, but even that’s not working. I searched through all my flies and can’t find one error that would cause this. I tried uninstalling and reinstalling the program multiple times, and that doesn’t work. What should I do? Thanks, Ed Sent from Mail for Windows 10 -- https://mail.python.org/mailman/listinfo/python-list
giving error during installation (ez_setup.py given error could not create ssl/tls secure channel)
Hello, can you please help regarding this problem. ez_setup.py given error could not create ssl/tls secure channel Regards Syed Shujaat -- https://mail.python.org/mailman/listinfo/python-list
Re: Python in endless loop
YnIk wrote: > Dear Python, > Hello. This is an email concerning about my Python program(3.7.0). It > keeps printing out stuff that’s too fast to read. If I try to write code, > it just keeps on going. I have tried Ctrl+C, but even that’s not working. > I searched through all my flies and can’t find one error that would cause > this. I tried uninstalling and reinstalling the program multiple times, > and that doesn’t work. What should I do? Thanks, Ed Run the script from the command line and feed the output to the more utility: C:\> py path\to\myscript.py | more Do not type the C:\> which is a placeholder for the command prompt; you should be seeing something similar. Once you have a rough idea where the problem occurs you can add print statements to inspect the value of the problematic variables. A tad more advanced: your editor (which one?) may support setting "breakpoints" and running the script under a debugger step by step or until it hits a breakpoint. If you need help with debugging and your script is short you may also post it here or provide a link to the source code. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python in endless loop
On Sep 17, 2018 9:31 AM, "YnIk" wrote: > > Dear Python, > Hello. This is an email concerning about my Python program(3.7.0). It keeps printing out stuff that’s too fast to read. If I try to write code, it just keeps on going. I have tried Ctrl+C, but even that’s not working. I searched through all my flies and can’t find one error that would cause this. I tried uninstalling and reinstalling the program multiple times, and that doesn’t work. What should I do? What did you do to install python? What action(s) do you take after installation that lead to the problem? Where does the output appear? Normally output appears in a window. Does this window have a title; if so what is it? You try yo write code. That presumes some kind of editor or command window. How do you get this window; what is it's title? I assume you mean "files". Do you literally search the thousands of files that are a part of a Windows installation? If not, which files? What are you looking for (when you say "error")? Please be as explicit as possible. We don't have ESP or crystal balls. > Thanks, Ed > > Sent from Mail for Windows 10 > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Zen of The Python Mailing List
change of subject, wanted to add this : previous messages are worth a read Abdur-Rahmaan Janhangeer Mauritius -- Forwarded message - From: Abdur-Rahmaan Janhangeer Date: Mon, 17 Sep 2018, 19:18 Subject: Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause To: Cc: python-ideas Zen of The Python Mailing List >>> import that on topic is better than off topic the dish of toxicity is made up of opinion attacking irony is it's fine herbs top posting should be counselled homeworks are not to be done mail clients are the tastes and colours of life a mailing list serves it's purpose, unless specified ideas are the flagship of focus balazing pingponging is sign of Zen explosion RTFM has kinder alternatives good english is preferred, but makes you not a better programmer -- https://mail.python.org/mailman/listinfo/python-list
Re: Experiences with a programming exercise
On Sep 15, 2018 1:50 PM, "Alister via Python-list" wrote: > > On Sat, 15 Sep 2018 17:08:57 +, Stefan Ram wrote: > > > I gave two different functions: > > > > def triangle(): > > for i in range( 3 ): > > forward( 99 ); left( 360/3 ) > > > > def rectangle() > > for i in range( 4 ): > > forward( 99 ); left( 360/4 ) > > > > , and the exercise was to write a single definition for a function > > »angle( n )« that can be called with »3« to paint a triangle and with > > »4« to paint a rectangle. Nearly all participants wrote something like > > this: > > > > def angle( n ): > > if n == 3: > > for i in range( 3 ): > > forward( 99 ); left( 360/3 ) > > if n == 4: > > for i in range( 4 ): > > forward( 99 ); left( 360/4 ) > > > > Now I have added the requirement that the solution should be as short > > as possible! My candidate for shortest expression: [( forward( 99 ), left( 360/n)) for x in 'a'*n] > > seems a good exercise & you are breaking the students in step by stem > which is also good > get something that works, then make it better > > i would suggest instead of the new requirement to be make it a short as > possible make it work with ANY number of sides. > > > > > -- > Max told his friend that he'd just as soon not go hiking in the > hills. > Said he, "I'm an anti-climb Max." > [So is that punchline.] > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
how to get string printed by PyErr_Print( )
Hey, Someone has discussed this issue before. Other than redirect stderr, does the new version python 3.7.0 has other way to retrieve the string whichPyErr_Print( ) ? if (PyErr_Occurred()) PyErr_Print(); //need to retrieve the error to string Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: giving error during installation (ez_setup.py given error could not create ssl/tls secure channel)
Syed Shujaat writes: > can you please help regarding this problem. ez_setup.py given error could not > create ssl/tls secure channel Apparently, "ez_setup.py" tries to upgrade a transport communication channel with SSL (= "Secure Socket Layer") or TLS (= "Transport Layer Security") and fails. Unfortunately, this may have many possible causes -- among others: * it may be a temporary problem on the server side (and go away automatically after perhaps an hour, a day) * the trusted certificate information on your host may be missing or outdated; as a consequence, the server certificate presented during SSL/TSL negociation could not be verified * the "ez_setup.py" may be too old and its connection information outdated. * ... What can you do? Each potential cause requires cause specific action. Temporary problem: retry after some time (an hour, a day). If the error persists, it is likely not a temporary problem. Trusted certificate information: it is usually stored at a central place on your host and shared by all applications. If you install a browser, it typically comes with up-to-date trusted certificate information. Up-to-date "ez_Setup.py": are you sure, you are using an up-to-date "ez_Setup.py". If not, search and download an up-to-date one. -- https://mail.python.org/mailman/listinfo/python-list
