Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • May 10 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 27 19:46
    @mstellaluna banned @zhonghuacx
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:04
    @mstellaluna banned @dertiuss323
  • Jan 07 15:43
    User @mstellaluna unbanned @oudarjya718
  • Jan 06 15:14
    @mstellaluna banned @oudarjya718
  • Dec 15 2018 23:38
    @mstellaluna banned @Julianna7x_gitlab
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 22:59
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:13
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 27 2018 19:07
    User @mstellaluna unbanned @JomoPipi
  • Aug 27 2018 06:17
    @mstellaluna banned @JomoPipi
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:15
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
Momozor
@momozor
pardon my English
Momozor
@momozor
From the functional programming aspect.
Vishesh Mangla
@XtremeGood
hi can someone here help me with mergesort in python?
def merge(l, start, mid, end):
    i = start
    j = mid + 1
    temp = []
    while i <= mid and j <= end:
        if l[i] < l[j]:
            temp.append(l[i])
            i += 1
        else: 
            temp.append(l[j])
            j += 1 

    if i==mid and j<end:
        while j <= end:
            temp.append(l[j])
            j += 1
    elif i < mid and j==end:
        while i <= mid:
            temp.append(l[i])
            i += 1

    for i in range(len(temp)):
        l[i + start] = temp[i]
how is the mine above code different from this?
def merge(Arr, start, mid, end) :

    # create a temp array
    temp[] = [0] * (end - start + 1)

    # crawlers for both intervals and for temp
    i, j, k = start, mid+1, 0

    # traverse both lists and in each iteration add smaller of both elements in temp 
    while(i <= mid and j <= end) :
        if(Arr[i] <= Arr[j]) :
            temp[k] = Arr[i]
            k += 1; i += 1
        else :
            temp[k] = Arr[j]
            k += 1; j += 1

    # add elements left in the first interval 
    while(i <= mid) 
        temp[k] = Arr[i]
        k += 1; i += 1

    # add elements left in the second interval 
    while(j <= end)
        temp[k] = Arr[j]
        k += 1; j += 1

    # copy temp to original interval
    for(i = start; i <= end; i += 1)
        Arr[i] = temp[i - start]
below one works from iterviewbits website
see the while loops in the if conditions
Blauelf
@Blauelf
@momozor You always pass a value, just that references are values, too. There is no automatic shallow/deep copy (because different scenarios would require different kinds of copies).
Blauelf
@Blauelf
@XtremeGood First one appends, second one preallocates the full array (which is probably more efficient). The first uses l[i] < l[j], the second uses Arr[i] <= Arr[j] (which I would prefer, as it preserves order among equal elements, makes the sort "stable"). First one is off by one in those extra comparisons, if i==mid and j<end: would have to be if i>mid and j<=end:, but that does not add any value, so second one does not have any.
Still not sure whether those final loops are any more efficient than for example temp[k:k+mid-i+1] = Arr[i:mid+1], but I could guess my method might be implemented by removing and inserting the range.
Momozor
@momozor
@Blauelf ah I see. thanks
iwillsolo
@iwillsolo
Hello guys, i made my first scraping script works perfect (not that much) and it get some user inputs for some options, now i want to give it to some of my friends for testing purposes but i need to protect it with some serial key or something similar so they don't give it to someone else to use it
Is that a possible thing?
divyajeetsingh
@divyajeetsingh
hi , buddy
any idea of image cropping and merging in image
Ocheer Zundekoff
@Zund87
Hi, guis! Please, tell me about your favorite freelance python/django etc websites?!
John Melody Melissa
@johnmelodyme
Is there possible to write android application completely in python (android studio)?
Christoffer
@Conan88
Good morning! Would it be a problem to have your tests as @staticmethod? Must not be confused with testing static methods =)
Christoffer
@Conan88
@johnmelodyme There are some frameworks out there that lets you do that like BeeWare. Havent tested it though
Jason Stokes
@jpstokes
Hey just created a new platform to help developers find jobs. Sign up for an account @ www.quirkycoders.com so that employers can find you.
Edoardo Gallo
@EdoardoGallo_twitter
Hello guys! i've some problem using patch to mock uuid.uuid4() during tests. Basically i have a BaseClass with an id attribute (the uuid to mock), many other Children Classes that add attributes but share the same uuid.
These Children will be used around the application and i'd need to mock/control the result of uuid4() everywhere during the test.
# message.py

from uuid import uuid4

class Message:
  def __init__(self, **kwargs):
    self.id = kwargs.pop('id', str(uuid4()))

# -----

# connect.py

from .message import Message

class Connect(Message):
  def __init__(self, custom):
    self.method = 'custom_method'
    params = {
      'custom': custom
    }
    super().__init__(params=params)
I then use Connect() in other modules that i want to test. How can i patch the uuid4() result in the base class Message?
Edoardo Gallo
@EdoardoGallo_twitter
i tried with @patch.object(path.to.message, 'uuid4', return_value='1') but then connect.py will grab the original Message class, not the mocked one.
Fotis Karioris
@fotiskar
Hello I'm trying to install selenium and chromedriver on windows but when I run the pip command I get requirement satisfied. When I try to run a script though I get the following error output: FATAL ERROR :: Selenium and Selenium Chrome webdriver must be installed on your system to run this program.
Any ideas?
Blauelf
@Blauelf
So both are on your computer? Do you have to specify the path somewhere?
Hopkins Nji
@HopkinsNji_twitter
@fotiskar what version of python are you using and what version of python is pip installing to?
Josebuendia
@Josebuendia
How do I change Python from 2.7 to an updated version? I downloaded the Windows v. no.3.7.4 then downloaded it using: Windows x86-64 web-based installer then went to the Cmd, typed python -V and then: C:\Users\finta>python -V
Python 2.7.15
Nadia
@nadiaschutz
hey guys trying to fix my terminal command python so that it would use python 3 on default. I am working on MAC. so created .bashrc and changed .bash_profile
# bash_profile
export PATH="/usr/local/opt/icu4c/bin:$PATH"
export PATH="/usr/local/opt/icu4c/sbin:$PATH"
export PATH="/usr/local/opt/icu4c/bin:$PATH"

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
export CLICOLOR=1
export PATH=$PATH:./node_modules/.bin

if [[ -s ~/.bashrc ]]; then
    source ~/.bashrc;
fi
# .bashrc


export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
alias ls='ls -GFh'

orange=$(tput setaf 166);
yellow=$(tput setaf 288);
green=$(tput setaf 71);
white=$(tput setaf 15);
bold=$(tput bold);
reset=$(tput sgr0);

PS1="custom-> ";
PS1="\[${bold}\]\n";
PS1+="\[${orange}\]\u"; #username
PS1+="\[${white}\] at ";
PS1+="\[${yellow}\]\h" #host;
PS1+="\[${white}\] in ";
PS1+="\[${green}\]\W"; #working directory
PS1+="\n"
PS1+="\[${white}\]\$ \[${reset}\]";
export PS1;
# User specific aliases and functions
# . .alias
# alias ducks='du -cks * | sort -rn | head -15'
alias python='python3'


# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi


PATH=$PATH:/home/username/bin:/usr/local/homebrew
export PATH
and for some reasons any of those not working
any tips?
Nadia
@nadiaschutz
never mind
i had to remove this part from .bashrc to make it work
# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi
Josebuendia
@Josebuendia

I must have the latest version of python if when I go to Chrome Downloads & save as the Python file and open it it asks me not if I want to install it be if I want to modify or repair it. So, why then does the Command line say: C:\Users\finta>python
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>

Steve (Gadget) Barnes
@GadgetSteve
@Josebuendia Presumably you are trying to install and have already installed Python 3.7 or 3.8 rc. The problem is that you also have, as your default python, python 2.7.15. Running, from the command line, py -0pwill give you a list with paths of your installed pythons. If you re-run the latest installer, select the modify option, and ensure that you tick "Add to path" and "Make this my default python" (then click next several times) it will resolve the issue on and new command line prompts.
Josebuendia
@Josebuendia
If you re-run the latest installer, select the modify option, and ensure that you tick "Add to path" and "Make this my default python" it doesn't give the option to do that.
Brent Arias
@brentarias
Does anyone know how well a conda environment facilitates pip? I want to create a conda environment (conda create -n foobar) and then within that run pip install -r requirements.txt. I'm not sure if this will add the packages to a system-wide registry or base environment, or if it will be properly isolated to the conda environment?
Ezequiel Salas
@ezequielsalas
Hello @brentarias, whenever you run pip install -r requirements.txt you are installing all the packages from requirements.txt to the active environment. If you haven't activated any environment the packages will be installed to a system-wide.
Brent Arias
@brentarias
@ezequielsalas What you say is true when using an environment created with virtualenv or venv. But what about an environment created using conda?
Ezequiel Salas
@ezequielsalas
As you can see in this documentation https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html they said that you have to activate the environment just like Virtualenv
@brentarias
Brent Arias
@brentarias
@ezequielsalas Yes the conda environment must be explicitly activated if it is a conda version prior to 4.6. Otherwise no. But that link you gave says nothing about the behavior of pip install inside of a conda environment. Keep in mind that a conda environment is not a wrapper around a virtualenv. Instead, a conda environment is an entirely different technology.
Sabe Barker
@SabeBarker
slipsnip
@slipsnip
Is there a link to terms of use for this room?
Christo Rafa Castle
@Angeles4four
That's a great question, @slipsnip . I'm wondering about the Terms of Service here too.
slipsnip
@slipsnip
@Angeles4four thanks
Bazmahou
@hamzabouissi_gitlab
hello