python-2.7

Plotly legend next to each subplot, Python

杀马特。学长 韩版系。学妹 提交于 2021-02-13 07:51:48
问题 After noticing that there was no answer to this question at the moment, I would like to know if anyone has an idea how to: Have a legends for each subplot. Group legends by name. (Ex: for different subplots, all have the same two curves but with different values). Here's my Plotly script: from plotly import tools import plotly.plotly as py import plotly.graph_objs as go import plotly nom_plot=[] trace1 = go.Scatter(x=[1, 2, 3], y=[4, 5, 6],name='1',showlegend=True) nom_plot.append('GRAPH 1')

How do I make the screen ignore the background color of some image?

馋奶兔 提交于 2021-02-12 09:22:31
问题 I'm using python 2.7, and I am currently working on a basic game in pyagme for my school work. I downloaded an image from google, and it has a background color and I know it's RGB. I remember that there is a method that makes the screen ignore this RGB for the picture (the picture will appear without the background color) but I don't remember it. import pygame WINDOW_WIDTH = 1200 WINDOW_LENGTH = 675 IMAGE = r'C:\Users\omero\Downloads\BattleField.jpg' PISTOL_IMAGE = r'C:\Users\omero\Downloads

Cannot revoke_ingress for non-default VPC with boto3

坚强是说给别人听的谎言 提交于 2021-02-11 17:19:27
问题 AWS Lambda / python 2.7 / boto3 I'm trying to revoke one rule out of many in a security group ( SG_we_are_working_with ) but receive error An error occurred (InvalidGroup.NotFound) when calling the RevokeSecurityGroupIngress operation: The security group 'sg-xxxxx' does not exist in default VPC 'none' The SG is really not in the default VPC but custom one, but I mention VPC id explicitly! SG_we_are_working_with = 'sg-xxxxx' SG_which_is_the_source_of_the_traffic = 'sg-11111111' VpcId = 'vpc

parse xpath from xml file should contain '

烂漫一生 提交于 2021-02-11 15:55:49
问题 this is my xml file <Item name="Date" xpath='p[@class="date"]/text()' defaultValue="Date Not Found"></Item> i parse it like this: self.doc=etree.parse(xmlFile) masterItemsFromXML = self.doc.findall('MasterPage/MasterItems/Item') for oneItem in masterItemsFromXML: print 'master item xpath = {0}'.format(oneItem.attrib['xpath']) and I can see the result printed in the cmd like this: master item xpath =p[@class="date"]/text() my problem the xpath is not valid because it should start with ' and

parse xpath from xml file should contain '

痞子三分冷 提交于 2021-02-11 15:55:21
问题 this is my xml file <Item name="Date" xpath='p[@class="date"]/text()' defaultValue="Date Not Found"></Item> i parse it like this: self.doc=etree.parse(xmlFile) masterItemsFromXML = self.doc.findall('MasterPage/MasterItems/Item') for oneItem in masterItemsFromXML: print 'master item xpath = {0}'.format(oneItem.attrib['xpath']) and I can see the result printed in the cmd like this: master item xpath =p[@class="date"]/text() my problem the xpath is not valid because it should start with ' and

Anaconda install pyipopt: libipopt.so.1

瘦欲@ 提交于 2021-02-11 15:52:35
问题 I'm completely new to Python and most aspects of compiling C. My default python interpreter is the anaconda interpreter for python 2.7. I'm trying to install pyipopt following these instructions: https://github.com/xuy/pyipopt. Pyipopt installed to /usr/local/lib/python2.7/dist-packages/pyipopt , but when I try import pyipopt I get an error saying that pyipopt wasn't found. I then tried copying the installed folder into Anaconda's pkgs folder. At first it said Error: import pyipopt

Anaconda install pyipopt: libipopt.so.1

大憨熊 提交于 2021-02-11 15:52:07
问题 I'm completely new to Python and most aspects of compiling C. My default python interpreter is the anaconda interpreter for python 2.7. I'm trying to install pyipopt following these instructions: https://github.com/xuy/pyipopt. Pyipopt installed to /usr/local/lib/python2.7/dist-packages/pyipopt , but when I try import pyipopt I get an error saying that pyipopt wasn't found. I then tried copying the installed folder into Anaconda's pkgs folder. At first it said Error: import pyipopt

Pygame choose which display to use in fullscreen [duplicate]

喜你入骨 提交于 2021-02-11 15:40:23
问题 This question already has answers here : pygame dual monitors and fullscreen (2 answers) Closed last month . This is the code: #!/usr/bin/python import pygame, sys from pygame.locals import * import Tkinter as tk root = tk.Tk() pygame.init() w = 640 h = 400 RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) PINK = (255, 0, 255) CYAN = (0, 255, 255) WHITE = (255, 255, 255) screen = pygame.display.set_mode((w,h), RESIZABLE) clock = pygame.time.Clock() x = y = 100

Kivy: Modifying a child widget of another separate class

眉间皱痕 提交于 2021-02-11 15:21:45
问题 im currently looking into kivy to start with crossplatform development. i have a bit of python experience (but basic) and now wanted to code a little game in kivy to get into. i probably wont finish this but i like learning stuff while doing it with something im intrested in. Anyway my "App" is supposed to be seperated in two seperate "screens" the top one is only used for displaying stuff and the all interactive stuff is controlled from the bottom "screen". Now i want to display some text in

Function to return a formatted string in python

◇◆丶佛笑我妖孽 提交于 2021-02-11 15:21:38
问题 A function which returns a formatted string by replacing all instances of %X with Xth argument in args (0...len(args)) Example: simple_format("%1 calls %0 and %2", "ashok", "hari")=="hari calls ashok and %2" Please help me out. 回答1: >>> "{1} calls {0} and {2}".format( "ashok", "hari", "tom") 'hari calls ashok and tom' If you really need the function simple_format , then: import re def simple_format(*args): s = re.sub(r'%(\d+)', r'{\1}', args[0]) return s.format(*args[1:]) Example: >>> simple