Mailing List Archive

Problem with python
Hi there.
I downloaded python a couple of days ago from the official site and
have started writing simple programs in the python gui (this being my
first attempt at programming ever). The only thing is when I write
python code in a text editor and save it as a .py file, when I double
click it all that happens is a black box flashes up on the screen, but
nothing else!?

At first I thought this was because I had only written a hello world
program, and that the box had displayed "hello world" and then closed.
But then I wrote a program requiring user input and the same thing
happened... Am I doing something wrong?

Thanks in advance for any help!

//mac
--
http://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On Mar 30, 2:57 am, mac_the_sco...@hotmail.com wrote:
> Hi there.
> I downloaded python a couple of days ago from the official site and
> have started writing simple programs in the python gui (this being my
> first attempt at programming ever). The only thing is when I write
> python code in a text editor and save it as a .py file, when I double
> click it all that happens is a black box flashes up on the screen, but
> nothing else!?
>
> At first I thought this was because I had only written a hello world
> program, and that the box had displayed "hello world" and then closed.
> But then I wrote a program requiring user input and the same thing
> happened... Am I doing something wrong?
>
> Thanks in advance for any help!
>
> //mac

open the program in IDLE (or any other Python IDEs). I'm guessing that
your program is printing a traceback (error) when trying to get input
that's why it immediately closes itself.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
Lie wrote:
> On Mar 30, 2:57 am, mac_the_sco...@hotmail.com wrote:
>> Hi there.
>> I ... started writing simple programs in the python gui... when I write
>> python code ...[and]... double click it all that happens is a black box
>> flashes up on the screen, but nothing else!? ....
>
> open the program in IDLE (or any other Python IDEs). I'm guessing that
> your program is printing a traceback (error) when trying to get input
> that's why it immediately closes itself.

Another possibility is to open a shell (or command window or "dos box"),
and in that window type in "python myfile.py" You'll see error messages
because the display window does not depend on the program staying alive.

By the way, a better thing to have said when you asked this would
include your OS, the python version, and the GUI system you are using.
Those details matter. If you are doing wxPython programming, for
example, you cannot easily use IDLE for your program (GUI systems
fight for control of the display).

-Scott David Daniels
Scott.Daniels@Acm.Org
--
http://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On Mar 29, 5:33 pm, Scott David Daniels <Scott.Dani...@Acm.Org> wrote:
> Lie wrote:
> > On Mar 30, 2:57 am, mac_the_sco...@hotmail.com wrote:
> >> Hi there.
> >> I ... started writing simple programs in the python gui...  when I write
> >> python code ...[and]... double click it all that happens is a black box
> >> flashes up on the screen, but nothing else!? ....
>
> > open the program in IDLE (or any other Python IDEs). I'm guessing that
> > your program is printing a traceback (error) when trying to get input
> > that's why it immediately closes itself.
>
> Another possibility is to open a shell (or command window or "dos box"),
> and in that window type in "python myfile.py" You'll see error messages
> because the display window does not depend on the program staying alive.
>
> By the way, a better thing to have said when you asked this would
> include your OS, the python version, and the GUI system you are using.
> Those details matter.  If you are doing wxPython programming, for
> example, you cannot easily use IDLE for your program (GUI systems
> fight for control of the display).

The screen is real (r-e-a-l): all manners intended. Real. Just bid
and auction.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On Mar 30, 12:34 am, castiro...@gmail.com wrote:
>
> The screen is real (r-e-a-l): all manners intended.  Real.  Just bid
> and auction.
>

Please leave the newbies alone. They have enough trouble just getting
their Python environments running, without trying to decipher your
pseudo-profound chatterbot-speak.

-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
mac_the_sco...@hotmail.com wrote to me:
(snip)
> OK thanks mate you're the man :)
> One more question though :P
> If I write a python script in a text editor (I use Programmers
> Notepad), how do I write indentations properly? e.g.:
> ---------------------------------------------------
> temperature = input("How hot is the spam? ")
> while temperature < hot_enough:
> print "Not hot enough... Cook it a bit more..."
> sleep(30)
> temperature = input("OK. How hot is it now? ")
> print "It's hot enough - You're done!"
>
> (taken from hetland.org)
> ---------------------------------------------------
> Is it simply a case of hitting the spacebar until it looks right?

Yep, it's just a matter of hitting spacebar until it looks right, but
you should also be aware that the Python Interpreter doesn't like it
if you mix tabs and spaces, so make sure you only use either one of
them. As an additional note, Python's style guideline says you should
use 4 spaces (additionally, most Python IDEs automatically convert
tabs into 4 spaces for convenience and to avoid mixing tabs and
cases).

PS: I'll mirror this to comp.lang.python
--
http://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On 9/4/21 12:27 PM, Igor Korot wrote:
> Hi, ALL,
>
> [code]
> igor@WaylandGnome ~/bakefile $ python
> Python 3.9.6 (default, Aug 8 2021, 17:26:32)
> [GCC 10.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from distutils import sysconfig
>>>> print sysconfig.get_python_inc()
> File "<stdin>", line 1
> print sysconfig.get_python_inc()
> ^
> SyntaxError: invalid syntax
>>>>
> [/code]
>
> What is the proper way to fix this?

print is a function in Python 3.

print(sysconfig.get_python_inc())

Try:

>>> help(print)

for a quick check.

--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On Sat, Sep 4, 2021 at 2:29 PM Igor Korot <ikorot01@gmail.com> wrote:
>
> Hi, ALL,
>
> [code]
> igor@WaylandGnome ~/bakefile $ python
> Python 3.9.6 (default, Aug 8 2021, 17:26:32)
> [GCC 10.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from distutils import sysconfig
> >>> print sysconfig.get_python_inc()
> File "<stdin>", line 1
> print sysconfig.get_python_inc()

print( sysconfig.get_python_inc())

Since python3 print is a function.
> ^
> SyntaxError: invalid syntax
> >>>
> [/code]
>
> What is the proper way to fix this?
>
> Thank you.
> --
> https://mail.python.org/mailman/listinfo/python-list



--
Joel Goldstick
--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On 05/09/2021 06.27, Igor Korot wrote:
> Hi, ALL,
>
> [code]
> igor@WaylandGnome ~/bakefile $ python
> Python 3.9.6 (default, Aug 8 2021, 17:26:32)
> [GCC 10.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from distutils import sysconfig
>>>> print sysconfig.get_python_inc()
> File "<stdin>", line 1
> print sysconfig.get_python_inc()
> ^
> SyntaxError: invalid syntax
>>>>
> [/code]
>
> What is the proper way to fix this?

Remember that in Python3 print became a function:

print( sysconfig.get_python_inc() )

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
Thx guys.
I submitted a bug report for the project that uses it.

On Sat, Sep 4, 2021 at 1:42 PM Joel Goldstick <joel.goldstick@gmail.com> wrote:
>
> On Sat, Sep 4, 2021 at 2:29 PM Igor Korot <ikorot01@gmail.com> wrote:
> >
> > Hi, ALL,
> >
> > [code]
> > igor@WaylandGnome ~/bakefile $ python
> > Python 3.9.6 (default, Aug 8 2021, 17:26:32)
> > [GCC 10.3.0] on linux
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> from distutils import sysconfig
> > >>> print sysconfig.get_python_inc()
> > File "<stdin>", line 1
> > print sysconfig.get_python_inc()
>
> print( sysconfig.get_python_inc())
>
> Since python3 print is a function.
> > ^
> > SyntaxError: invalid syntax
> > >>>
> > [/code]
> >
> > What is the proper way to fix this?
> >
> > Thank you.
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
>
>
> --
> Joel Goldstick
> --
> https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On 9/4/2021 2:27 PM, Igor Korot wrote:
> Hi, ALL,
>
> [code]
> igor@WaylandGnome ~/bakefile $ python
> Python 3.9.6 (default, Aug 8 2021, 17:26:32)
> [GCC 10.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from distutils import sysconfig

In 3.10, distutils and d.sysconfig are deprecated, with suggestions to
use setuptools or sysconfig modules instead.

>>>> print sysconfig.get_python_inc()
> File "<stdin>", line 1
> print sysconfig.get_python_inc()
> ^
> SyntaxError: invalid syntax

In interactive mode, print is not usually needed.

>>> sysconfig.get_python_inc()
'C:\\Programs\\Python310\\include'


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
Hi,
Will this syntax work in python 2?

Thank you.

On Sat, Sep 4, 2021 at 1:52 PM dn via Python-list
<python-list@python.org> wrote:
>
> On 05/09/2021 06.27, Igor Korot wrote:
> > Hi, ALL,
> >
> > [code]
> > igor@WaylandGnome ~/bakefile $ python
> > Python 3.9.6 (default, Aug 8 2021, 17:26:32)
> > [GCC 10.3.0] on linux
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> from distutils import sysconfig
> >>>> print sysconfig.get_python_inc()
> > File "<stdin>", line 1
> > print sysconfig.get_python_inc()
> > ^
> > SyntaxError: invalid syntax
> >>>>
> > [/code]
> >
> > What is the proper way to fix this?
>
> Remember that in Python3 print became a function:
>
> print( sysconfig.get_python_inc() )
>
> --
> Regards,
> =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
Igor Korot <ikorot01@gmail.com> writes:

> Hi,
> Will this syntax work in python 2?

If you say

print(something)

it works in both. So, stick to this syntax.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On 2021-09-04 14:29:47 -0500, Igor Korot wrote:
> Will this syntax work in python 2?

Yes. It's just a redundant pair of parentheses.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Re: Problem with python [ In reply to ]
Well, up to a point.
In Python 2 the output from
??? print 1, 2
is '1 2'
In Python 3 if you add brackets:
??? print(1, 2)
the output is the same.
But if you transplant that syntax back into Python 2, the output from
??? print(1, 2)
is '(1, 2)'.? The brackets have turned two separate items into a single
tuple.
If you want Python 2- and 3-compatibility you must find a work-around
such as
??? print('%d %d' % (1,2))
??? print('%s %s' % (1,2))
??? print(str(1) + ' ' + str(2))

Similarly
??? 'print' in Python 2 outputs a blank line.
??? 'print()' in Python 3 outputs a blank line.? In python 2 it prints
a line containing a blank tuple: '()'.
A 2/3-compatible way of outputting a blank line is
??? print('')

Best wishes
Rob Cliffe




On 04/09/2021 20:50, Peter J. Holzer wrote:
> On 2021-09-04 14:29:47 -0500, Igor Korot wrote:
>> Will this syntax work in python 2?
> Yes. It's just a redundant pair of parentheses.
>
> hp
>
>

--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On 2021-09-04 21:07:11 +0100, Rob Cliffe via Python-list wrote:
> Well, up to a point.
> In Python 2 the output from
> ??? print 1, 2
> is '1 2'
> In Python 3 if you add brackets:
> ??? print(1, 2)
> the output is the same.
> But if you transplant that syntax back into Python 2, the output from
> ??? print(1, 2)
> is '(1, 2)'.? The brackets have turned two separate items into a single
> tuple.

Yes. I was just talking about that specific case with a single function
call. I do not consider explaining the differences between Python 2 and
Python 3 to be time well spent in 2021, especially not to someone who
apparently just wants to report a bug to some unnamed project (whose
maintainers may or may not care about Python2 compatibility).

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Re: Problem with python [ In reply to ]
On Sat, 4 Sep 2021 22:41:12 +0200, "Peter J. Holzer" <hjp-python@hjp.at>
declaimed the following:

>Python 3 to be time well spent in 2021, especially not to someone who
>apparently just wants to report a bug to some unnamed project (whose
>maintainers may or may not care about Python2 compatibility).
>

Given the nature of the error reported by the OP... It may be closer to
state "whose maintainers may or may not care about" /Python3/
"compatibility"; the code appears to already be Python2 compatible <G>



--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On 2021-09-04, Peter J. Holzer <hjp-python@hjp.at> wrote:
> On 2021-09-04 14:29:47 -0500, Igor Korot wrote:
>> Will this syntax work in python 2?
>
> Yes. It's just a redundant pair of parentheses.

Not really. With the parens, it doesn't produce the same results in
2.x unless you import the print function from the future:

Python 3.9.6 (default, Aug 9 2021, 12:35:39)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print(1,2)
1 2

Python 2.7.18 (default, Jul 18 2021, 14:51:54)
[GCC 10.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print(1,2)
(1, 2)

Python 2.7.18 (default, Jul 18 2021, 14:51:54)
[GCC 10.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> print(1,2)
1 2




--
https://mail.python.org/mailman/listinfo/python-list
Re: Problem with python [ In reply to ]
On 2021-09-04, Hope Rouselle <hrouselle@jevedi.com> wrote:
> Igor Korot <ikorot01@gmail.com> writes:
>
>> Hi,
>> Will this syntax work in python 2?
>
> If you say
>
> print(something)
>
> it works in both.

But it doesn't always work the _same_ in both. If you're expecting
some particular output, then one or the other might not won't "work".

> So, stick to this syntax.

Only if you import print_function from __future__ in 2.x

--
Grant


--
https://mail.python.org/mailman/listinfo/python-list