python-3.3

Ubuntu - How to install a Python module (BeautifulSoup) on Python 3.3 instead of Python 2.7?

随声附和 提交于 2019-12-03 05:25:13
I have this code (as written in BS4 documentaion): from bs4 import BeautifulSoup When I run the script (using python3) I get the error: ImportError: No module named 'bs4' So installed BeatifulSoup by: sudo pip install BeatifulSoup4 But when I try to run the script again I get the same error. Indeed BS4 is installed in: BeautifulSoup4 in /usr/local/lib/python2.7/dist-packages But I want to install and use it with python3.3 (as there are other module which are not working with python2.7). I tried with: virtualenv --python=/usr/bin/python2.7 /usr/bin/python3.3 and then install BS4 again, but

itertools.accumulate() versus functools.reduce()

扶醉桌前 提交于 2019-12-03 01:53:21
In Python 3.3, itertools.accumulate() , which normally repeatedly applies an addition operation to the supplied iterable, can now take a function argument as a parameter; this means it now overlaps with functools.reduce() . With a cursory look, the main differences between the two now would seem to be: accumulate() defaults to summing but doesn't let you supply an extra initial condition explicitly while reduce() doesn't default to any method but does let you supply an initial condition for use with 1/0-element sequences, and accumulate() takes the iterable first while reduce() takes the

How to update values to the listbox under Combobox in ttk Python33

孤者浪人 提交于 2019-12-03 00:43:43
When I create the Combobox, it has no items in the list. Now when I click on the dropdown button a function is called (via the postcommand option), but once in my function I don't know how to set the values in the listbox of the Combobox. Code something like this: #update list upon drop down self.cbox = Combobox(self, width = 10, postcommand = self.updtcblist) def updtcblist(self): list = self.getPortLst() self.cbox.getlistbox.set(list) #getlistbox doesn't work Thanks, Harvey Answered my own question. I Finally found an example that helped, and got it to work with the following code: #update

How to stack indices and given values

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 16:59:30
问题 seq1_values = [5, 40, 180, 13, 30, 20, 25, 24, 29, 31, 54, 46, 42, 50, 67, 17, 76, 33, 84, 35, 100, 37, 110, 32, 112, 15, 123, 3, 130, 42] def get_num_values(): global seq1_values return len( seq1_values ) def get_values(): global seq1_values for value in seq1_values: yield value yield None def next_value(): return next( next_value.values ) next_value.values = get_values() def main(): numbers = [] value = next_value() while value is not None: numbers.append(value) input_size = len(numbers)-1

How do I add Python 3.3 to Powershell?

六眼飞鱼酱① 提交于 2019-12-02 13:24:54
问题 Hey I've been trying to add Python 3.3 to windows powershell by repacing 27 with 33 in the path. I tried to post a screenshot but turns out I need 10 rep so I'll just copy and paste what I've attempted: [Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33", "User") > [Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33") > [Enviroment]::SetEnviromentVariable("Path", "$env:Path;C:\Python33\python.exe", "User") > [Enviroment]::SetEnviromentVariable("Path", "$env:Path

NumPy in IDLE (Python 3.3.2) on Mac OSx 10.8

蓝咒 提交于 2019-12-02 13:13:38
问题 I know this may be a repeat question, but all the answers I've found on here are WAY above my head. I'm very new at Python, but I would like to use NumPy in IDLE (python 3.3.2). IDLE doesn't seem to access the numpy that comes w/ OSX 10.8 (which is python 2.7). I can't find a Numpy for Python 3 installer for Mac OSX. All of the instructions I've found are very complicated and assume I know a lot more than I do and they still wouldn't help me get it into IDLE even if I could execute them. Can

list comprehension to repeat element in a list by element value

旧街凉风 提交于 2019-12-02 13:05:23
I can't quite figure out the code to do this, there are similar posts: Repeating elements in list comprehension but I want to repeat a value in the list by the value in the list In [219]: l = [3,1] [i for x in range(i) for i in l] --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-219-84d6f25dfd96> in <module>() 1 l = [3,1] 2 ----> 3 [i for x in range(i) for i in l] TypeError: 'tuple' object cannot be interpreted as an integer What I want is a list like so: [3,3,3,1] Also can someone explain the error. Note I

unexpected end of regular expression

落爺英雄遲暮 提交于 2019-12-02 08:56:42
问题 I want to get only the file name with extension from the path: C:\\Users\\anandada\\workspace\\MyTestProject\\src\\OpenTest.c The statement below, fileName = re.match("[^\\]*.c$", fileName) gives error: unexpected end of regular expression I am using python 3.3.2 回答1: You need to double the doubled escapes again , or use a raw string instead: fileName = re.match("[^\\\\]*.c$",fileName) or fileName = re.match(r"[^\\]*.c$",fileName) otherwise first Python, then the regular expression compiler

How to stack indices and given values

╄→尐↘猪︶ㄣ 提交于 2019-12-02 08:20:30
seq1_values = [5, 40, 180, 13, 30, 20, 25, 24, 29, 31, 54, 46, 42, 50, 67, 17, 76, 33, 84, 35, 100, 37, 110, 32, 112, 15, 123, 3, 130, 42] def get_num_values(): global seq1_values return len( seq1_values ) def get_values(): global seq1_values for value in seq1_values: yield value yield None def next_value(): return next( next_value.values ) next_value.values = get_values() def main(): numbers = [] value = next_value() while value is not None: numbers.append(value) input_size = len(numbers)-1 for i in range(input_size): print("|", str(input_size).rjust(4), end="") for j in range(input_size):

NumPy in IDLE (Python 3.3.2) on Mac OSx 10.8

血红的双手。 提交于 2019-12-02 06:58:26
I know this may be a repeat question, but all the answers I've found on here are WAY above my head. I'm very new at Python, but I would like to use NumPy in IDLE (python 3.3.2). IDLE doesn't seem to access the numpy that comes w/ OSX 10.8 (which is python 2.7). I can't find a Numpy for Python 3 installer for Mac OSX. All of the instructions I've found are very complicated and assume I know a lot more than I do and they still wouldn't help me get it into IDLE even if I could execute them. Can anyone point me to instructions for BEGINNERS on this installation? For example, most start with a