-
-
Webmaster4o
x.split()
will give you each word as an element in a list. So, to get the second word of your sentence, you usex.split()[1]
.You could do something like:
words = x.split() if words[0].lower() == "jump": second_word = x.split()[1]
-
Webmaster4o
There may be an API incompatibility with iOS 10, I'm sure @omz will fix it soon enough
-
Webmaster4o
The Pythonista turtle module is rewritten completely from the desktop module, so I don't know if there's complete feature parity, but in the desktop module I think you can use
turtle.speed(0)
. Give it a try and let me know. -
Webmaster4o
When we were discussing a cleaner
objc_util
syntax a few months ago, the suggestion of using kwargs was rejected because there as no way to guarantee the order. However, look at this from the Python 3.6 release notes!**kwargs
in a function signature is now guaranteed to be an insertion-order-preserving mapping.This is from PEP 468
Unless I'm mistaken, this would enable that syntax.
-
Webmaster4o
@mikael I'm actually currently working on the same thing for https://zeit.co/now
-
Webmaster4o
@Phuket2 A github repo just for your experiments would be a good way to organize them, I think
-
Webmaster4o
One tip for making text more readable is something the Material Design guidelines recommend: While white text should be
rgba(255, 255, 255, 1)
, but black text should bergba(0, 0, 0, 0.87)
. The slight opacity in the black makes it much more readable on colored backgrounds. -
Webmaster4o
@SpiesWithin This example is correct.
client
is defined withclient = discord.Client()
-
Webmaster4o
@ccc It does, but it can't possibly convert them back into tuples.
In [2]: a = livejson.File("/Users/luke/Desktop/a.json") In [3]: a["b"] = (0, 1, 2, 3) In [4]: a["b"] Out[5]: [0, 1, 2, 3]
-
Webmaster4o
How to use
discord.py
has nothing to do with Pythonista itself. Why don't you read the example on the page you linked:import discord import asyncio client = discord.Client() @client.event async def on_ready(): print('Logged in as') print(client.user.name) print(client.user.id) print('------') @client.event async def on_message(message): if message.content.startswith('!test'): counter = 0 tmp = await client.send_message(message.channel, 'Calculating messages...') async for log in client.logs_from(message.channel, limit=100): if log.author == message.author: counter += 1 await client.edit_message(tmp, 'You have {} messages.'.format(counter)) elif message.content.startswith('!sleep'): await asyncio.sleep(5) await client.send_message(message.channel, 'Done sleeping') client.run('token')
I'm not sure whether
asyncio
works in Pythonista, though, it may not. The last time I used Discord.py was almost a year ago, and it didn't use asyncio at that point. I believe there's still a legacy API available. -
-
Webmaster4o
JSON doesn't have tuples, just lists.
livejson
intentionally leaves the serialization of more complex types to the user. Iflivejson
handled this itself, it would lose compatibility with other languages and modules. It wouldn't be hard to store a datetime object in JSON as a timestamp, though, and then decode that out. If you really need to use a tuple, you can convert it afterlivejson
is done with it.This isn't the most friendly approach, I know, but
livejson
's core philosophy is that there is as little abstraction as possible.livejson
is supposed to be simple, easy, and efficient to use.livejson
is supposed to be just an interface to your data, not a simple-looking module that keeps lots of hidden attributes behind the curtains. As soon as it gets into the business of custom encodings, it loses compatibility with other modules.The reason for this is, to put it simply simply, that nearly every programming language can read and write JSON, and can convert timestamps to dates and back. But Python
datetime
objects aren't the same as those in Ruby or PHP.I know livejson is a Python module, but allowing tuples or datetime objects isn't in the spirit of JSON. JSON is a simple, minimal data serialization format that is extendable to almost every language. Anything python-specific about the way
livejson
stores data would defeat the purposeThat's why
livejson
doesn't have methods for working with complex objects. You as the user are encouraged to reduce your objects to the simplest possible form (like alist
for atuple
or a timestamp for adatetime
object), because that way it's simple, straightforward, and universal. -
Webmaster4o
You can't. You'll have to rewrite your code using
scene
. -
Webmaster4o
@chriswilson The advantage is that with a client-side library, you can do real-time animations, tooltips, and interaction. But you'll have to know a bit of JS to get through it (though JS isn't hard)
-
-
Webmaster4o
None of the above. Rendering in the back-end is almost always a bad idea. Browsers are built to render content. By rendering images on your server, you're putting unnecessary load on your server, and sacrificing both interactivity and accessibility. Use http://chartjs.org/ instead.
-
Webmaster4o
You can't. Services like
Twilio charge a lot of money for this functionality.See pricing tables on their website. It may seem cheap, but it counts up quickly.
-
Webmaster4o
Sorry, I didn't mean to sound so harsh. I was just trying to point out that there is an existing bug tracker for StaSh.