Rustom Mody writes:
> You may find this strategy useful:
> https://pchiusano.github.io/2015-04-23/unison-update7.html
>
> particularly the section "Limitations of refactoring via modifying
> text files in place, and what to do instead"
A direct link to that section is
https://pchiusano.github.io
On Thursday, January 21, 2016 at 7:53:07 PM UTC+5:30, Charles T. Smith wrote:
> What does "from (module) import (func)" do?
>
> Please don't tell me that I shouldn't ask because real programmers
> know not to have circular dependencies ...
>
> I have no idea what was imported before. I just want
Terry Reedy writes:
> But fails with remainder 0, as others noted. Lesson: include corner
> cases in validation test. Anyway, my main point about writing a clear
> spec remains true.
My validation test for this was to loop both numerator and denominator
from -5 to 5 (skipping denominator 0) to
On 2016-01-21, Chris Angelico wrote:
On Thu, Jan 21, 2016 at 6:18 PM, Frank Millman wrote:
Fedora 22 comes standard with Python 3.4.2. I want to install 3.5.1.
It is easy enough to download the source and run ./configure;make;make
altinstall. But then I find that I cannot import gzip because
On Fri, 22 Jan 2016 12:59 pm, Grobu wrote:
> On 21/01/16 09:39, Shiyao Ma wrote:
>> Hi,
>>
>> I wanna simulate C style integer division in Python3.
>>
>> So far what I've got is:
>> # a, b = 3, 4
>>
>> import math
>> result = float(a) / b
>> if result > 0:
>>result = math.floor(result)
>> else
On 1/21/2016 9:56 PM, Terry Reedy wrote:
On 1/21/2016 3:39 AM, Shiyao Ma wrote:
I wanna simulate C style integer division in Python3.
There are two problems with this spec: it assumes that 'C style integer
division' is well defined and that we know the definition. Better:
"How do I write a
On 1/21/2016 3:39 AM, Shiyao Ma wrote:
I wanna simulate C style integer division in Python3.
There are two problems with this spec: it assumes that 'C style integer
division' is well defined and that we know the definition. Better:
"How do I write a function 'div' in Python 3 so that the f
On 21/01/16 09:39, Shiyao Ma wrote:
Hi,
I wanna simulate C style integer division in Python3.
So far what I've got is:
# a, b = 3, 4
import math
result = float(a) / b
if result > 0:
result = math.floor(result)
else:
result = math.ceil(result)
I found it's too laborious. Any quick way?
On 21 January 2016 at 21:17, Marko Rauhamaa wrote:
> Well, then there's:
>
> def intdiv(a, b):
> return int(a / b)
That depends on how accurate you need it to be
>>> def intdiv(a, b):
... return a//b if (a < 0) == (b < 0) else -(-a//b)
...
>>> num = 3**171
>>> num
387021023451030799
Random832 :
> On Thu, Jan 21, 2016, at 09:31, Marko Rauhamaa wrote:
>> Maybe:
>>
>>def intdiv(a, b):
>>return a // b if (a < 0) == (b < 0) else -(-a // b)
>
> Personally, I like a // b + (a % b and a ^ b < 0) - I've done the
> opposite in C to get python-style division.
Well, then th
On Thu, Jan 21, 2016, at 09:31, Marko Rauhamaa wrote:
> Maybe:
>
>def intdiv(a, b):
>return a // b if (a < 0) == (b < 0) else -(-a // b)
Personally, I like a // b + (a % b and a ^ b < 0) - I've done the
opposite in C to get python-style division.
--
https://mail.python.org/mailman/li
Robert wrote:
> Hi,
>
> I read below code snippet on link:
> https://docs.python.org/2/library/functions.html#property
>
> --
> class C(object):
> def __init__(self):
> self._x = None
>
> def getx(self):
> return self._x
>
> def setx(self, value):
>
On Thu, 21 Jan 2016 16:30:30 +, Charles T. Smith wrote:
>> Side observation: 'int' is a bad name for a package, because it will
>> shadow the name of the 'int' built-in.
>
>
> Boy oh boy have I experienced that now! :)
(it wasn't me! ;) )
--
https://mail.python.org/mailman/listinfo/python
On Thu, 21 Jan 2016 08:59:39 -0700, Ian Kelly wrote:
> What happens if you just do 'import utilities'. Can you then call
> utilities.hexdump? Can you see anything in the utilities module?
Yes, that works! That's what I'm doing as a work around.
I was trying to avoid doing that because I figured
On Fri, 22 Jan 2016 02:53 am, Charles T. Smith wrote:
> What I need is tools to find the problems. In particular, why doesn't
> python give me more of a clue where the problem is? It would be cool
> if it would tell me exactly what module to look at, which symbol(s)
> were colliding.
The proble
On Fri, 22 Jan 2016 02:12 am, Charles T. Smith wrote:
> On Thu, 21 Jan 2016 07:52:17 -0700, Ian Kelly wrote:
>
>>> I have no idea what was imported before. I just want to import
>>> hexdump(). Unfortunately, this does not work:
>>>
>>> from utilities import hexdump
>>>
>>> ImportError: can
On Thu, Jan 21, 2016 at 8:12 AM, Charles T. Smith
wrote:
>>> would you explain to me why I get this:
>>>
>>> (PDB)hexdump(msg)
>>> *** NameError: name 'hexdump' is not defined
>>
>> Probably because the name 'hexdump' is not defined.
>
>
> If indeed it's not defined, then I wouldn't think there'
In "Charles T. Smith"
writes:
> > How did this error come up? Did the code work previously? If so, what
> > changed?
> The developers of this legacy code had this as well as other functions
> duplicated throughout the system, in order to avoid confronting these
> issues.
Yes, but did the co
On Thu, 21 Jan 2016 15:44:43 +, John Gordon wrote:
> In that case, the problem is most likely a circular import issue, as you
> mentioned. The only way to fix it is to reorganize your modules.
>
> How did this error come up? Did the code work previously? If so, what
> changed?
What I nee
Thanks all for the answers.
Oscar Benjamin wrote:
print(('{}th\n' * len(a)).format(*a))
print(''.join(map('{}th\n'.format, a)))
Those two look closest to what I was hoping for, I guess, but as Chris
Angelico said, it probably is clearer to just loop over the range.
--
https://mail.
On Thu, Jan 21, 2016 at 1:18 AM, Frank Millman wrote:
> Hi all
>
> Fedora 22 comes standard with Python 3.4.2. I want to install 3.5.1.
>
> It is easy enough to download the source and run ./configure;make;make
> altinstall. But then I find that I cannot import gzip because zlib-devel is
> missing
On Thu, 21 Jan 2016 15:44:43 +, John Gordon wrote:
> How did this error come up? Did the code work previously? If so, what
> changed?
The developers of this legacy code had this as well as other functions
duplicated throughout the system, in order to avoid confronting these
issues. I'm tr
On Thu, 21 Jan 2016 15:31:45 +, John Gordon wrote:
> The most likely explanation here is that the 'utilities' module simply
> does not contain something named 'hexdump'.
>
> Have you inspected the 'utilities' module? Does it, in fact, contain
> something named 'hexdump'?
Yes
--
https://ma
In "Charles T. Smith"
writes:
> > The most likely explanation here is that the 'utilities' module simply
> > does not contain something named 'hexdump'.
> >
> > Have you inspected the 'utilities' module? Does it, in fact, contain
> > something named 'hexdump'?
> Yes
In that case, the proble
In "Charles T. Smith"
writes:
> from utilities import hexdump
> ImportError: cannot import name hexdump
The most likely explanation here is that the 'utilities' module simply
does not contain something named 'hexdump'.
Have you inspected the 'utilities' module? Does it, in fact, conta
On Thu, 21 Jan 2016 07:52:17 -0700, Ian Kelly wrote:
>> I have no idea what was imported before. I just want to import
>> hexdump(). Unfortunately, this does not work:
>>
>> from utilities import hexdump
>>
>> ImportError: cannot import name hexdump
>
> What is utilities? Is it a module on
On Jan 21, 2016 7:31 AM, "Charles T. Smith"
wrote:
>
> What does "from (module) import (func)" do?
Approximately equivalent to:
import module
func = module.func
Except that it doesn't bind "module" to anything.
> Please don't tell me that I shouldn't ask because real programmers
> know not to
Marko Rauhamaa writes:
> Jussi Piitulainen writes:
>
>> Steven D'Aprano writes:
>>
>>> So my guess is that the fastest, and certainly the most obvious, way
>>> to get the same integer division behaviour as C99 would be:
>>>
>>> def intdiv(a, b):
>>> # C99 style integer division with truncation
On 1/21/2016 8:27, Chris Angelico wrote:
This is a Linux packaging question, more than a Python one. On Debian
systems, the way to do that is "apt-get build-dep python3"; check your
own package manager for an equivalent - it'll probably be called
builddep or similar.
Yes, you'd run:
dnf buil
On 2016-01-21, Chris Angelico wrote:
> On Thu, Jan 21, 2016 at 6:18 PM, Frank Millman wrote:
>> Fedora 22 comes standard with Python 3.4.2. I want to install 3.5.1.
>>
>> It is easy enough to download the source and run ./configure;make;make
>> altinstall. But then I find that I cannot import gzi
Jussi Piitulainen :
> Steven D'Aprano writes:
>
>> So my guess is that the fastest, and certainly the most obvious, way
>> to get the same integer division behaviour as C99 would be:
>>
>> def intdiv(a, b):
>> # C99 style integer division with truncation towards zero.
>> n = a//b
>> if
What does "from (module) import (func)" do?
Please don't tell me that I shouldn't ask because real programmers
know not to have circular dependencies ...
I have no idea what was imported before. I just want to import hexdump().
Unfortunately, this does not work:
from utilities import hexdump
On 1/21/2016 15:00, Jussi Piitulainen wrote:
Steven D'Aprano writes:
So my guess is that the fastest, and certainly the most obvious, way
to get the same integer division behaviour as C99 would be:
def intdiv(a, b):
# C99 style integer division with truncation towards zero.
n = a//b
Steven D'Aprano writes:
> So my guess is that the fastest, and certainly the most obvious, way
> to get the same integer division behaviour as C99 would be:
>
> def intdiv(a, b):
> # C99 style integer division with truncation towards zero.
> n = a//b
> if (a < 0) != (b < 0):
>
On Thu, 21 Jan 2016 08:11 pm, Ben Finney wrote:
> Shiyao Ma writes:
>
>> I wanna simulate C style integer division in Python3.
>
> I'm not sure I know exactly what behaviour you want (“C style” may mean
> different things to each of us).
Surely is means "whatever the C standard defines integer
On Thu, 21 Jan 2016 06:30 pm, Paulo da Silva wrote:
> Hi all.
>
> What is the fastest implementation of the following code?
Let's find out. Here are three different ways to do it:
def g(p):
return
def f1(p=3): # argument with a default
return g(p)
def f2(): # no argument at all
I literally just installed pyGame under 3.5.1, using following .whl file
that pulled off a site offering collections of .whl files:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
And, according to following page, the command of pi3p install
...followed by name of .whl file... handled installing pyG
Hi!
I have now spent several hours trying to install Pygame with Python
3.5. I have installed from a msi file "successfully" but "import
pygame" fails either because Python can't find pygame or because "%1 is
not a valid .DLL". I have followed the instructions at
https://www.webucator.com/b
On 21 January 2016 at 08:39, Shiyao Ma wrote:
>
> I wanna simulate C style integer division in Python3.
>
> So far what I've got is:
> # a, b = 3, 4
>
> import math
> result = float(a) / b
> if result > 0:
> result = math.floor(result)
> else:
> result = math.ceil(result)
>
>
> I found it's to
Jussi Piitulainen writes:
> Shiyao Ma writes:
>
>> I wanna simulate C style integer division in Python3.
>>
>> So far what I've got is:
>> # a, b = 3, 4
>>
>> import math
>> result = float(a) / b
>> if result > 0:
>> result = math.floor(result)
>> else:
>> result = math.ceil(result)
>>
>> I fou
Paul Rubin writes:
> Ben Finney writes:
>> I'm not sure I know exactly what behaviour you want (“C style” may mean
>> different things to each of us).
>
> I thought he meant trunc-division, so -5 / 2 = -2 and -5 % 2 = -1.
> Python specifies floor division but C leaves it unspecified, I thought.
I
Ben Finney writes:
> I'm not sure I know exactly what behaviour you want (“C style” may mean
> different things to each of us).
I thought he meant trunc-division, so -5 / 2 = -2 and -5 % 2 = -1.
Python specifies floor division but C leaves it unspecified, I thought.
--
https://mail.python.org/ma
Paulo da Silva wrote:
> Hi all.
>
> What is the fastest implementation of the following code?
>
> def g(p):
> ...
> return something
>
> def f1(p="p1"):
> return g(p)
>
> def f2(p="p2"):
> return g(p)
>>> def g(p): return p.upper()
...
>>> def f1(): pass
...
>>> f1.__code__ = g.__code__
>>>
Shiyao Ma writes:
> I wanna simulate C style integer division in Python3.
I'm not sure I know exactly what behaviour you want (“C style” may mean
different things to each of us).
I'll point out that Python's ‘//’ operator specifies floor division
https://docs.python.org/3/reference/expressions.
Shiyao Ma writes:
> I wanna simulate C style integer division in Python3.
>
> So far what I've got is:
> # a, b = 3, 4
>
> import math
> result = float(a) / b
> if result > 0:
> result = math.floor(result)
> else:
> result = math.ceil(result)
>
> I found it's too laborious. Any quick way?
The
Apparently the thread poster cannot receive email, I just received a bounce
on my previous email :-/
On Thu, Jan 21, 2016, 08:49 Yann Kaiser wrote:
> partial treats keyword arguments as default values, though they become
> keyword-only as a result :
>
> f1 = functools.partial(g, p="p1")
>
> On T
Shiyao Ma wrote:
>Hi,
>I wanna simulate C style integer division in Python3.
>So far what I've got is:
># a, b = 3, 4
>import math
>result = float(a) / b
>if result > 0:
> result = math.floor(result)
>else:
> result = math.ceil(result)
>I found it's too laborious. Any quick way?
In Python3
You can use the // operator, which should do what you want.
On Thu, Jan 21, 2016, 09:40 Shiyao Ma wrote:
> Hi,
>
> I wanna simulate C style integer division in Python3.
>
> So far what I've got is:
> # a, b = 3, 4
>
> import math
> result = float(a) / b
> if result > 0:
> result = math.floor(r
On Wed, 20 Jan 2016 11:30:19 -0800
Mansi wrote:
> Hello,
>
> I just installed Python 3.5.1 but anytime I use Pycharm, a prompt of whether
> I want to modify, repair or uninstall Python keeps on coming up. Even while
> I'm in the midst of typing a program. Please advise.
I believe, You should
Hi,
I wanna simulate C style integer division in Python3.
So far what I've got is:
# a, b = 3, 4
import math
result = float(a) / b
if result > 0:
result = math.floor(result)
else:
result = math.ceil(result)
I found it's too laborious. Any quick way?
--
吾輩は猫である。ホームーページはhttps://introo.me
50 matches
Mail list logo