python

python open() - access denied

浪子不回头ぞ 提交于 2021-02-20 19:36:55
问题 This is my first post on stackoverflow, so if somethings wrong I'm eager to learn! I'm programming a plugin for Cinema 4d with python. Everything works on Mac, but I'm having problems on Windows with what I'm about to explain. The plugin needs a path to a server, in case of rendering on a renderserver. I want the user to enter the path once, and to then store it in a .txt file. for c4d, plugins are being installed, by draging-and-droping the plugin into the plugin folder at for example: C:

python open() - access denied

我怕爱的太早我们不能终老 提交于 2021-02-20 19:36:13
问题 This is my first post on stackoverflow, so if somethings wrong I'm eager to learn! I'm programming a plugin for Cinema 4d with python. Everything works on Mac, but I'm having problems on Windows with what I'm about to explain. The plugin needs a path to a server, in case of rendering on a renderserver. I want the user to enter the path once, and to then store it in a .txt file. for c4d, plugins are being installed, by draging-and-droping the plugin into the plugin folder at for example: C:

how do I dynamically resize a pixbuf cellrenderer in a treeview?

末鹿安然 提交于 2021-02-20 19:33:22
问题 I'm using a Gtk3 TreeView that looks like above. The model is a Gtk.TreeStore Gtk.TreeStore(str, GdkPixbuf.Pixbuf) For the picture I could add to the model the correctly sized images via: pixbuf.scale_simple(48,48,GdkPixbuf.InterpType.BILINEAR) However I'm also using the model elsewhere showing the pixbufs in a different manner and the pixbufs can also be a variety of sizes. What I would like to do is force the size of the picture displayed at run-time. The question is - how do I do that? I

Why is my superclass calling my subclass method?

 ̄綄美尐妖づ 提交于 2021-02-20 19:33:09
问题 When I call a method that was overrided from my constructor, I am getting an error and it says that it is missing an argument (due to the subclass requiring a second argument). However, I called the method in the super(), so why doesn't it call the super class version of that method? This is best illustrated with a short example: class A: def __init__(self): self.do() def do(self): print("A") class B(A): def __init__(self): super().__init__() self.do("B") def do(self, arg2): super().do()

Find most frequent row or mode of a matrix of vectors - Python / NumPy

懵懂的女人 提交于 2021-02-20 19:32:53
问题 I have a numpy array of shape (?,n) that represents a vector of n-dimensional vectors. I want to find the most frequent row. So far it seems that the best way is to just iterate over all the entries and store a count, but it seems obscene that numpy or scipy wouldn't have something builtin to perform this task. 回答1: Here's an approach using NumPy views , which should be pretty efficient - def mode_rows(a): a = np.ascontiguousarray(a) void_dt = np.dtype((np.void, a.dtype.itemsize * np.prod(a

Python Datetime: All Items From Yesterday

夙愿已清 提交于 2021-02-20 19:26:26
问题 In Python, if I wanted to do a check for all items from yesterday would I do something like: from datetime import datetime, timedelta if datetime.datetime.today() - timedelta(days=2) < item_to_check < datetime.datetime.today(): Would this pull all items from yesterday and is this the best way to do it? 回答1: I'd try something easier ;-) from datetime import date, timedelta yesterday = date.today() - timedelta(days=1) if item_to_check.date() == yesterday: # yup! Note that your: item_to_check <

Convert a list of dictionaries into a set of dictionaries

て烟熏妆下的殇ゞ 提交于 2021-02-20 19:22:08
问题 How can i make a set of dictionaries from one list of dictionaries? Example: import copy v1 = {'k01': 'v01', 'k02': {'k03': 'v03', 'k04': {'k05': 'v05'}}} v2 = {'k11': 'v11', 'k12': {'k13': 'v13', 'k14': {'k15': 'v15'}}} data = [] N = 5 for i in range(N): data.append(copy.deepcopy(v1)) data.append(copy.deepcopy(v2)) print data How would you create a set of dictionaries from the list data ? NS: One dictionary is equal to another when they are structurally the same. That means, they got exactly

pip is not installing my data_files. But easy_install does

余生长醉 提交于 2021-02-20 19:16:20
问题 This is going to be a short question. The source is here: https://github.com/exhuma/grc And the title explains my problem ;) I registered and uploaded the package to pypi . Now if I run easy_install grc , it works as expected. But if I run pip install grc , it installs properly, but does not install the data_files. I don't see why this is happening. Any ideas? 回答1: Maybe the files aren't installed in the path you expect. In Ubuntu 11.10, I see them under /usr/local/configs as it can be seen

Why is smtplib.SMTP().sendmail not sending a DKIM signed message

帅比萌擦擦* 提交于 2021-02-20 19:14:41
问题 I have set up postfix on a server, along with openDKIM. When I run: echo "Testing setup" | mail -s "Postfix test" {my_email_address} I get the email, and in the mail headers there is a DKIM-Signature header. When, however I write a python script to send an email, using smtplib: import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.utils import make_msgid msg = MIMEMultipart('alternative') part1 = MIMEText('Hello, world', 'plain') msg

Why is smtplib.SMTP().sendmail not sending a DKIM signed message

社会主义新天地 提交于 2021-02-20 19:14:30
问题 I have set up postfix on a server, along with openDKIM. When I run: echo "Testing setup" | mail -s "Postfix test" {my_email_address} I get the email, and in the mail headers there is a DKIM-Signature header. When, however I write a python script to send an email, using smtplib: import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.utils import make_msgid msg = MIMEMultipart('alternative') part1 = MIMEText('Hello, world', 'plain') msg