Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: fixed width numbers
Post: RE: fixed width numbers
Yeah I misread. See what Larz60+ wrote. That's the best way to do it. |
|
Nwb |
General Coding Help |
15 |
8,577 |
May-26-2019, 03:01 PM |
|
|
Thread: fixed width numbers
Post: RE: fixed width numbers
Ah okay so you want to add leading zeroes.
You can use string formatting to do this very easily.
print(f'{number:0(length)}')
eg:
>>> print(f'{10:020}')
00000000000000000010 |
|
Nwb |
General Coding Help |
15 |
8,577 |
May-26-2019, 08:16 AM |
|
|
Thread: fixed width numbers
Post: RE: fixed width numbers
How are you getting leading zeroes anyway?
For leading spaces you can use either append to your string or make use of more than one argument to your print function.
print( 1*' ' + str(number+100000... |
|
Nwb |
General Coding Help |
15 |
8,577 |
May-26-2019, 05:41 AM |
|
|
Thread: What are some pythonic phrases?
Post: RE: What are some pythonic phrases?
|
Nwb |
News and Discussions |
7 |
3,157 |
May-25-2019, 03:16 PM |
|
|
Thread: What are some pythonic phrases?
Post: RE: What are some pythonic phrases?
|
Nwb |
News and Discussions |
7 |
3,157 |
May-11-2019, 04:19 PM |
|
|
Thread: About integer objects vs integer values
Post: RE: About integer objects vs integer values
(Apr-28-2019, 08:57 PM)Skaperen Wrote: someone here thinks the reference count increases when an assignment is made? well, OK, so. that is an internal detail. not that i would think anyone would ... |
|
Nwb |
News and Discussions |
18 |
7,795 |
Apr-29-2019, 03:33 PM |
|
|
Thread: What are some pythonic phrases?
Post: RE: What are some pythonic phrases?
Thaz really cool. Thanks a lot! |
|
Nwb |
News and Discussions |
7 |
3,157 |
Apr-28-2019, 02:36 PM |
|
|
Thread: What are some pythonic phrases?
Post: What are some pythonic phrases?
I've heard three pythonic phrases namely, "if it looks like a duck.. it's a duck"; "ask for forgiveness not permission"; "duck punching" (guess it's a term and not a phrase)
What are some other pyth... |
|
Nwb |
News and Discussions |
7 |
3,157 |
Apr-28-2019, 01:38 PM |
|
|
Thread: About integer objects vs integer values
Post: RE: About integer objects vs integer values
Why are statements in a function compiled together? And what do you mean they are compiled together? Python doesn't just interpret line by line? |
|
Nwb |
News and Discussions |
18 |
7,795 |
Apr-28-2019, 01:32 PM |
|
|
Thread: About integer objects vs integer values
Post: RE: About integer objects vs integer values
(Apr-27-2019, 04:31 PM)Gribouillis Wrote: Nwb Wrote:But in Python, assigning to an integer variable would mean allocating new memory for a new objectThis is not true. Assigning to an integer variabl... |
|
Nwb |
News and Discussions |
18 |
7,795 |
Apr-28-2019, 04:02 AM |
|
|
Thread: About integer objects vs integer values
Post: RE: About integer objects vs integer values
Quote:rumor is that ints, floats, and complexes are immutable. my guess is that bools are, too.
but does it really matter as long as the behavior is as if it is a referenceable object?
Yes they're a... |
|
Nwb |
News and Discussions |
18 |
7,795 |
Apr-27-2019, 12:32 PM |
|
|
Thread: About integer objects vs integer values
Post: About integer objects vs integer values
Would it be more efficient to have integers represented by objects or values?
Eg if it's represented by an object,
Var = 5
Var points to an object which has the value '5'
Var = 5
Var is a location in ... |
|
Nwb |
News and Discussions |
18 |
7,795 |
Apr-25-2019, 04:55 AM |
|
|
Thread: About [from FILE import FUNC]
Post: RE: About [from FILE import FUNC]
Why is it not circular import when I use
from a2 import *
Why does that work?? |
|
Nwb |
General Coding Help |
7 |
3,584 |
Apr-21-2019, 01:22 PM |
|
|
Thread: About [from FILE import FUNC]
Post: RE: About [from FILE import FUNC]
I don't think you understood my thread snippsat.
Try running the example I have given.
Why does from a2 import bob work and
from a2 import * not work?
They are supposed to do the same thing right? |
|
Nwb |
General Coding Help |
7 |
3,584 |
Apr-21-2019, 11:53 AM |
|
|
Thread: About [from FILE import FUNC]
Post: RE: About [from FILE import FUNC]
snippsat, I do know how to import? But I wanted to know what caused my observation and the alternative. |
|
Nwb |
General Coding Help |
7 |
3,584 |
Apr-21-2019, 10:29 AM |
|
|
Thread: About [from FILE import FUNC]
Post: About [from FILE import FUNC]
I've simplified what I observed to the smallest example I could. Here it is:
Here are two .py files a1.py and a2.py,
a1.py:
from a2 import bob
cobe = 5a2.py:
from a1 import cobe
bob = 4On running a1... |
|
Nwb |
General Coding Help |
7 |
3,584 |
Apr-21-2019, 07:51 AM |
|
|
Thread: Migration to a modern forum engine
Post: RE: Migration to a modern forum engine
So who funds this forum? What if the donations do not make it to the mark? Who pays? Python.org? |
|
Nwb |
Board |
21 |
13,911 |
Jan-30-2019, 11:42 AM |
|
|
Thread: I love the simplicity of Python but have a question
Post: RE: I love the simplicity of Python but have a que...
Quote:It's not exactly compiling, but there are applications that can create an .exe out of a Python program.
How do they do that? For instance Python allocates enough memory to store a number (corre... |
|
Nwb |
General Coding Help |
6 |
2,742 |
Jan-20-2019, 03:56 AM |
|
|
Thread: Question about exporting Python
Post: RE: Question about exporting Python
Ohh. I thought Python compilers actually compile the code.. I didn't realize they just bundle the interpreter with the source code.
On the contrary C generates machine code when it is compiled to an ... |
|
Nwb |
News and Discussions |
6 |
3,532 |
Jan-15-2019, 05:56 AM |
|
|
Thread: Question about exporting Python
Post: RE: Question about exporting Python
Buran that you've mentioned that you can bundle an interpreter to an executable,
-> How to do this? Can the interpreter be included in one binary file along with the application or does this have ... |
|
Nwb |
News and Discussions |
6 |
3,532 |
Jan-12-2019, 01:21 PM |