Re: Jython standalone
Am 15.11.15 um 01:35 schrieb [email protected]: Jython is python in java at jython.org. I tried clicking and double clicking. I does a wait cycle (rotating arrow) then returns to attention. I think you are describing the Windows mouse cursor that displays a rotating wheel to indicate "busy". Aren't you? From looking at the jython website, it states: Download Jython 2.7.0 - Standalone Jar : For embedding Jython in Java applications "embedding Jython in Java applications" means, that you can integrate it into a Java program that you are writing. You will not be able to double click and run this jar; it is a library, not an application. Try the installer instead. Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: pygtk beginner script not working
On Sat, Nov 14, 2015 at 05:00:59PM -0800, [email protected] wrote: > Hi guys > > I'm new to Python so please bare with me :) > > I'm using python 2.7.10 as advised (more tools apparently over 3.x) > > Trying to use this script > > [CODE] > #!/usr/bin/env python > > # example base.py > > import pygtk It makes most sense to use gtk3 and not gtk2. The most recenst version of gtk3 is used with gi package. Read this for example: http://python-gtk-3-tutorial.readthedocs.org/en/latest/introduction.html -- https://mail.python.org/mailman/listinfo/python-list
Format numbers
Just screwing around making up practice problems. I can't get the
format right. I am trying to learn how to get a output line to line
up neatly.
import random
lo=1
hi=1 # I am adding or subtracting 0s from this input number
fm=len(str(hi)) # This counts the digits of the input number
print fm
a=random.randrange(lo,hi+1)
count=0
guess=0
while guess != a:
guess=random.randrange(lo,hi + 1)
print "guess =",
print "{:8d}".format(guess), #what I would like to do is use
the variable fm instead of the number 8 here so the number of fields
are the same as the input number.
count+=1
if guess==a:
print " The hidden number was",a
print
print "You guessed right in ",
if guess >a:
print " Guess Lower"
hi=guess
if guess < a:
lo=guess
print " Guess Higher"
print count
print " turns"
--
https://mail.python.org/mailman/listinfo/python-list
Re: Format numbers
On 2015-11-15 17:30, Seymore4Head wrote:
Just screwing around making up practice problems. I can't get the
format right. I am trying to learn how to get a output line to line
up neatly.
import random
lo=1
hi=1 # I am adding or subtracting 0s from this input number
fm=len(str(hi)) # This counts the digits of the input number
print fm
a=random.randrange(lo,hi+1)
count=0
guess=0
while guess != a:
guess=random.randrange(lo,hi + 1)
print "guess =",
print "{:8d}".format(guess), #what I would like to do is use
the variable fm instead of the number 8 here so the number of fields
are the same as the input number.
count+=1
if guess==a:
print " The hidden number was",a
print
print "You guessed right in ",
if guess >a:
print " Guess Lower"
hi=guess
if guess < a:
lo=guess
print " Guess Higher"
print count
print " turns"
The part of the format placeholder that specifies the width can also be
placeholder, like this:
print "{:{}d}".format(guess, fm)
--
https://mail.python.org/mailman/listinfo/python-list
Re: Format numbers
On Sun, 15 Nov 2015 19:00:42 +, MRAB
wrote:
>On 2015-11-15 17:30, Seymore4Head wrote:
>> Just screwing around making up practice problems. I can't get the
>> format right. I am trying to learn how to get a output line to line
>> up neatly.
>>
>> import random
>> lo=1
>> hi=1 # I am adding or subtracting 0s from this input number
>> fm=len(str(hi)) # This counts the digits of the input number
>> print fm
>> a=random.randrange(lo,hi+1)
>> count=0
>> guess=0
>>
>> while guess != a:
>> guess=random.randrange(lo,hi + 1)
>> print "guess =",
>>
>> print "{:8d}".format(guess), #what I would like to do is use
>> the variable fm instead of the number 8 here so the number of fields
>> are the same as the input number.
>>
>> count+=1
>> if guess==a:
>> print " The hidden number was",a
>> print
>> print "You guessed right in ",
>> if guess >a:
>> print " Guess Lower"
>> hi=guess
>> if guess < a:
>> lo=guess
>> print " Guess Higher"
>> print count
>> print " turns"
>>
>The part of the format placeholder that specifies the width can also be
>placeholder, like this:
>
> print "{:{}d}".format(guess, fm)
That works
Thanks
--
https://mail.python.org/mailman/listinfo/python-list
Why won't this run?
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit
(AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> #this program says hello and asks for my name
>>> print:('Hello world!')
Hello world!
>>> print:('What is your name?') #ask for their name
What is your name?
>>> myName = input()
print:('It is good to meet you,'+myName)
>>> print:('The length of your name is:')
The length of your name is:
>>> print:(len(myName))
39
>>> print:('What is your age?')#ask for their age
What is your age?
>>> myAge=input()
print:('You will be ' + str(int(myAge)+1)'in a year.')
>>>
--
https://mail.python.org/mailman/listinfo/python-list
Re: Why won't this run?
On 2015-11-15 12:38, jbak36 wrote:
> Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC
> v.1900 64 bit (AMD64)] on win32 Type "copyright", "credits" or
> "license()" for more information.
> >>> #this program says hello and asks for my name
> >>> print:('Hello world!')
> Hello world!
Well, for starters, you're almost certainly not copy/pasting from the
shell session as the colon after the "print" is a syntax error:
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print:('hellow world!')
File "", line 1
print:('hellow world!')
^
SyntaxError: invalid syntax
-tkc
--
https://mail.python.org/mailman/listinfo/python-list
What meaning is 'a[0:10:2]'?
hi, When I learn slice, I have a new question on the help file. If I set: pp=a[0:10:2] pp is array([1, 3]) I don't know how a[0:10:2] gives array([1, 3]). I know matlab a lot, but here it seems quite different. Could you tell me what meaning a[0:10:2] is? Thanks, class slice(object) | slice(stop) | slice(start, stop[, step]) | | Create a slice object. This is used for extended slicing (e.g. a[0:10:2]). -- https://mail.python.org/mailman/listinfo/python-list
Re: What meaning is 'a[0:10:2]'?
(Please set a “From” address that has a name for you as an individual; “fl” is rather anonymous and doesn't help us to identify you in these conversations.) fl writes: > When I learn slice Are you working through the Python tutorial https://docs.python.org/3/tutorial/>? These are Python concepts that you will learn by working through the tutorial, from beginning to end. If you want to engage with a community dedicated to teaching Python newcomers, you should join the Python ‘tutor’ forum https://mail.python.org/mailman/listinfo/tutor>. -- \ “Philosophy is questions that may never be answered. Religion | `\ is answers that may never be questioned.” —anonymous | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: What meaning is 'a[0:10:2]'?
On 2015-11-15 16:27, fl wrote: > When I learn slice, I have a new question on the help file. If I > set: > > pp=a[0:10:2] > > pp is array([1, 3]) > > I don't know how a[0:10:2] gives array([1, 3]). > > I know matlab a lot, but here it seems quite different. Could you > tell me what meaning a[0:10:2] is? Well, if it a matlab.array was a well-behaved object it would just give you "0". As your copy/paste on the help for a slice stated, the first number is where it starts (0), the second number is where it ends (10, exclusive), and the 3rd number (2) is the stride. To demonstrate: >>> a = list(range(20)) >>> a [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] >>> a[0:10:2] [0, 2, 4, 6, 8] >>> a[:10:2] [0, 2, 4, 6, 8] >>> a[0:10] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] So note that the stride of 2 provides every other one while a stride of three provides every 3rd value >>> a[0:10:3] [0, 3, 6, 9] -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: What meaning is of '#!python'?
The installer of some applications will replace the shebang to refer to a specific version of Python. By doing so, it avoids problems when someone upgrades the default Python version in the PATH. On Nov 14, 2015 11:00 PM, "eryksun" wrote: > On Sat, Nov 14, 2015 at 8:26 PM, Zachary Ware > wrote: > > > > "#!python" is a valid shebang for the Python Launcher for Windows. > > It's also a not-too-terrible placeholder for a Unix shebang meaning > > "whichever Python you want it to be". The better choice for use with > > both platforms would be "#!/usr/bin/env python", though. > > The "/usr/bin/env python" virtual command searches the directories in > PATH, trying each file extension from PATHEXT such as "python.COM", > "python.EXE", and so on. You can also search for other programs such > as "pypy". Note that qualifying "python" (but not other names) as > "python2" or "python3.5" makes the launcher use the registry instead > of searching PATH. > > "#!/usr/bin/python" may be better in some cases. This defaults to the > latest installed version of 2.x (or 3.x if no 2.x is installed) that's > configured in the Windows registry. Or specify "python2" or "python3" > to use the latest 2.x or 3.x. These commands can be configured to use > a particular major[.minor[-32]] version via the environment variables > PY_PYTHON, PY_PYTHON2, and PY_PYTHON3. Or you can configure them > instead by setting the "python", "python2" and "python3" keys in the > [defaults] section of the configuration file "%LOCALAPPDATA%\py.ini". > Note that the environment variable overrides the corresponding py.ini > key. > > When portability isn't a concern you can use a Windows path in the > shebang such as "#!C:\pypy40\pypy.exe". > > https://docs.python.org/3/using/windows.html#shebang-lines > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Problems using struct pack/unpack in files, and reading them.
Dennis Lee Bieber wrote: And we'd be left looking for a symbol for bitwise inversion. Who needs negation when you have bitwise inversion? minusx = ~x + 1 I know, it doesn't work for floats, but that's just a simple matter of defining ~ on floats appropriately... -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Problems using struct pack/unpack in files, and reading them.
Ian Kelly wrote: Unary integer division seems pretty silly since the only possible results would be 0, 1 or -1. Ints are not the only thing that // can be applied to: >>> 1.0//0.01 99.0 -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Problems using struct pack/unpack in files, and reading them.
Chris Angelico wrote: Small problem: Since we have / and // operators, it's impossible to have a unary / operator: No, it's not -- '//' is already recognised as a single token distinct from '/ /'. You would just have to leave a space or use parens in some cases. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: What is wrong this wrapper (decorator)?
fl wrote: wrapper(sub(two, one)) Out[38]: This doesn't do what you probably meant it to do. It first calls sub() with arguments one and two, and then passes the result of that (a Coordinate, if sub is working properly) to wrapper(). Since wrapper() expects a function, not a Coordinate, that won't do anything useful. What you probably meant to do is: wrapper(sub)(one, two) This passes the function sub to wrapper, which returns another function; that function is then called with arguments one and two. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
