|
But he was saving them in the first example, sooo
|
# ? Jul 3, 2009 11:19 |
|
|
# ? May 28, 2024 18:51 |
|
Some europython materials are up: http://wiki.europython.eu/TalkMaterials Waiting on the eckel videos myself, his talks look to be interesting.
|
# ? Jul 3, 2009 15:25 |
|
Bonus posted:But he was saving them in the first example, sooo
|
# ? Jul 3, 2009 18:10 |
|
tef posted:Some europython materials are up: Where are the videos being posted?
|
# ? Jul 3, 2009 19:47 |
|
I assume they will appear here shortly: http://wiki.europython.eu/RecordedTalks
|
# ? Jul 3, 2009 19:50 |
|
supster posted:Where are the videos being posted? They'll probably be up on blip.tv
|
# ? Jul 3, 2009 19:51 |
|
what is the difference between a statement and an expression? how do eval and exec differ? why is assert needed? why not just use an if statement?
|
# ? Jul 5, 2009 05:05 |
|
CrazyPanda posted:what is the difference between a statement and an expression? These are a few statements: code:
code:
quote:how do eval and exec differ? quote:why is assert needed? why not just use an if statement? Scaevolus fucked around with this message at 05:38 on Jul 5, 2009 |
# ? Jul 5, 2009 05:31 |
|
Scaevolus posted:
Hi Scaevolus thank you for your response. im really new to programming so i dont understand the grammar page. is there something like grammar lite for beginners?
|
# ? Jul 5, 2009 06:41 |
|
CrazyPanda posted:Hi Scaevolus thank you for your response. im really new to programming so i dont understand the grammar page. is there something like grammar lite for beginners? Yes, precisely one section up: http://docs.python.org/reference/index.html
|
# ? Jul 5, 2009 07:08 |
|
CrazyPanda posted:Hi Scaevolus thank you for your response. im really new to programming so i dont understand the grammar page. is there something like grammar lite for beginners? It's in pseudo-BNF format, but it's not that important for you to understand right now.
|
# ? Jul 5, 2009 07:24 |
|
CrazyPanda posted:what is the difference between a statement and an expression? CrazyPanda posted:how do eval and exec differ? CrazyPanda posted:why is assert needed? why not just use an if statement? code:
|
# ? Jul 5, 2009 17:41 |
|
Newbie with python. I'm trying to automate a repetitive task, analyzing some data that's too big to put in Excel. The text files range from 6-30 megs. It usually crashes notepad too, but opens with wordpad. Will Python be able to handle this? The lines are arranged like so: 8.79669 5 5 5 5 I want to make it that so that python associates each column with its row. Then, if the third column is 5, to take the next 20 values of the third column and then average them, then spit that out into an output file with a small header. I'm not sure how to go about this. Thanks!
|
# ? Jul 5, 2009 20:44 |
|
PrinceofLowLight posted:Newbie with python. I'm trying to automate a repetitive task, analyzing some data that's too big to put in Excel. The text files range from 6-30 megs. It usually crashes notepad too, but opens with wordpad. Will Python be able to handle this? Python isn't a front end like notepad. You'll be able to open any file as long as your machine has the memory for it and you've coded the operations correctly. PS - notepad can't open the file because it has a limit on file size. Wordpad has a much higher limitation, if it has one at all. edit: also, for what you're describing you really only need to read one row at a time, which is fairly trivial. deedee megadoodoo fucked around with this message at 21:59 on Jul 5, 2009 |
# ? Jul 5, 2009 21:48 |
|
HatfulOfHollow posted:Python isn't a front end like notepad. You'll be able to open any file as long as your machine has the memory for it and you've coded the operations correctly. Notepad++ But if he's having trouble opening it on a modern Excel (I think 2003 was the first to get rid of the 65k row limit) then the files are huge.
|
# ? Jul 5, 2009 21:52 |
|
PrinceofLowLight posted:Newbie with python. I'm trying to automate a repetitive task, analyzing some data that's too big to put in Excel. The text files range from 6-30 megs. It usually crashes notepad too, but opens with wordpad. Will Python be able to handle this?
|
# ? Jul 6, 2009 00:04 |
|
Regular expressions? Seriously? http://docs.python.org/library/csv.html#module-csv is probably the easiest.
|
# ? Jul 6, 2009 00:20 |
|
Lonely Wolf posted:Regular expressions? Seriously? Well I was going to suggest a shell script. I'd just use "cut" or "sed" but it sounds like hes on windows. I didn't realize there was an actual CSV module (obviously he should use that if it exists), but when I did something like this before for parsing logs I ended up comparing pyparsing (obviously way overkill) and pythons re module and the re module wasn't too far behind doing it on the command line with cat and sed.
|
# ? Jul 6, 2009 00:23 |
|
I am having a bit of a hard time with python's threading functionality. I am trying to trying to build an object inside of gui class and the constructor takes a while to create the object. Without threading, the entire gui freezes up while waiting for the object to be created. Is there any way I can assign the constructor to a thread and then set the created object from the thread to an object inside of my gui class when it has completed?
|
# ? Jul 6, 2009 20:51 |
|
code:
|
# ? Jul 8, 2009 08:00 |
|
code:
|
# ? Jul 8, 2009 08:12 |
|
Isn't obvious? Each time you remove something from x, it skips the next item in x. You're not supposed to modify something you're currently iterating over. Why not just get a copy and then clear x? Or just point y to it? Why must you do it the manual way? Switch the references: x, y = y, x Switch in place, changing the lists, not the references: y.extend(x) del x[:]
|
# ? Jul 8, 2009 08:13 |
|
Balam posted:
I'm guessing when you remove the object from the list, you are altering the size of the list but the internal iterator doesn't adjust and it stops once it reaches the end of the list. code:
|
# ? Jul 8, 2009 08:22 |
|
hlfrk414 posted:Why must you do it the manual way? Actually, my goal is to simulate a deck of cards and handing them out to two empty lists representing the hands for the two players. I suppose I could just random.shuffle the deck and put the first half in one list and the second half in another list, then redefine the deck as an empty list, unless there is a good way to simulate passing a card out one at time until the deck list is empty. Other than that I was just curious why it wasn't working. Thanks for the help guys.
|
# ? Jul 8, 2009 10:40 |
|
MEAT TREAT posted:I'm guessing when you remove the object from the list, you are altering the size of the list but the internal iterator doesn't adjust and it stops once it reaches the end of the list. Ok, that makes senses, assuming that's the way it works. Thanks for explaining it.
|
# ? Jul 8, 2009 10:41 |
|
For general public information, these are some notes about Titanium. Titanium Appcelerator is an architecture, set of libraries and tools for making rich web applications, be they normal web apps or standalone desktop / mobile phone apps. What's the Python link? Python is one of the languages they support. In theory, you can have this very impressive rich visual apps driven by a Python backend. Since working with Plone is just one big headache (that you manage to get cured just before the next big headache comes along), I've been spending some time playing with it. - A variety of back ends are supported, for a variety of languages - For Python that means Google App Engine and Pylons. Django is mentioned, but the necessary code is missing. - And while "normal" web applications are supported, most of the focus is obviously on desktop and phone development - And actually the Pylons examples don't work as written. It's missing the necessary library for Appcelerator. - Install the necessary library for Appcelerator via easy_install and you get a different error - the library version is too new. - Argh - The documentation for Appcelerator is patchy, incomplete and outdated. Which makes it a perfect match for Pylons ... - And despite advice, writing your own service broker is far from straightforward In summary - not today. I'm going back to Django and Dojo, where documentation and examples aren't afterthoughts.
|
# ? Jul 8, 2009 15:11 |
|
Avenging Dentist posted:
Or if you need to change the pointed-to lists and not just the names x and y code:
|
# ? Jul 8, 2009 19:10 |
|
I'm having a strange issue with pygame. I copied an example straight out of the book, and it works just fine on my home computer, but when I use my work machine (a very locked down xp box), I get:code:
|
# ? Jul 9, 2009 13:44 |
|
Kire posted:I'm having a strange issue with pygame. I copied an example straight out of the book, and it works just fine on my home computer, but when I use my work machine (a very locked down xp box), I get:
|
# ? Jul 9, 2009 15:56 |
|
Is this fullscreen? If so, try making it windowed. My only guess is that a policy was added to prevent resizing the screen, and pygame fails when it tries to do it.
|
# ? Jul 10, 2009 09:55 |
|
scrabbleship posted:I am having a bit of a hard time with python's threading functionality. I am trying to trying to build an object inside of gui class and the constructor takes a while to create the object. Without threading, the entire gui freezes up while waiting for the object to be created. Is there any way I can assign the constructor to a thread and then set the created object from the thread to an object inside of my gui class when it has completed? What is it that takes so long? It seems pretty odd that just instantiating an object would necessitate spawning a whole new thread. In any case, GUI frameworks really don't work well with threading. If it doesn't totally blow up, there's plenty of other things that can go wrong. My guess is you're using GTK, and it has things in place to prevent people from doing stupid things like that.
|
# ? Jul 10, 2009 20:49 |
|
Here's a question that may or may not be silly. Let's say I'm writing a little card game in Python. I have my Card class that takes two integers that denote rank and suit. The __init__ then assigns the passed parameters to variables. My question is: Should I be validating the parameters passed when creating an object of this class, and if yes then how can I do that? I want something to happen if somewhere later in the code a Card object with rank 243 and suit -5 is created, but as I understand __init__ always returns None so I can't really be making any checks there. Right now I just get a Card object with rank 243 and suit -5. How do I check if the parameters passed when objects are created are valid?
|
# ? Jul 12, 2009 19:49 |
|
Zedlic posted:How do I check if the parameters passed when objects are created are valid? Exceptions, dude. (Or assertions.)
|
# ? Jul 12, 2009 19:55 |
|
Avenging Dentist posted:Exceptions, dude. (Or assertions.) Well don't I feel silly now. My mind was set on __init__ having to return something to signify an error. Thanks. I told you it was a silly question.
|
# ? Jul 12, 2009 20:47 |
|
Scaevolus posted:Is this fullscreen? If so, try making it windowed. It's windowed, so that's not it. Another question: I've never been able to get the event QUIT to work. All my pygame windows just hang when I click to close them, and I have to force-quit. I'm using the code right out of the book: code:
code:
|
# ? Jul 13, 2009 00:42 |
|
Kire posted:It's windowed, so that's not it. I think this is related to Tkinter, because I have the same "hanging window" problem any time I "update" an element of the window before actually packing the window up. Maybe somebody else could be more helpful here.
|
# ? Jul 13, 2009 19:02 |
|
Has anyone seen a pure Python implementation of a round robin archive type system anywhere? I have a project that RRD would work well for except the amount of data is going to cause disk I/O issues if I used the standard RRD package as nice as it is.
|
# ? Jul 15, 2009 06:37 |
|
I've been using some spare time to practice python by trying to find better, more elegant ways to solve a problem. Really, it's quite a lot of fun. This is such a breeze compared to C! Challenge: packet parsing. What's the cleanest, most elegant way to parse binary packet formats? Real-world motivation: you have to interface with an existing binary format, be it a network protocol or file. The thing is vast: implementing all of it in Python will take effort. Better make sure you're doing it right from the start. Goals, in order of difficulty: 1. Start with static-length, byte-aligned packets. 2. Move on to deal with dynamic length, embedded null-terminated strings, and occasional variations. 3. Move on to really dynamic/polymorphic packets with ever-changing encoding based on what came before (eg, an enum byte specifying how to decode the data that comes afterwards... many times in the same packet). 4. Just to make it worse, remove the byte-alignment assumption. The protocol is ancient, and bit-packed to save space! As the goals get harder, the problem of storing the data becomes more important. Using a function that returns a tuple of values is sufficient for small packets, but dictionaries must be used for the big polymorphic ones. There may be some middle ground for packet-classes in between: I wonder what the overhead is compared to dictionaries. So far, this is what I've learned: 1 is covered completely by the struct module! Fast (I assume it's implemented in C) cool syntactic sugar (a,b,c,d = unpack("4I", data)) and great support for padding/byte order. 2 raises the fun question, 'what is the neatest way to chop a chunk of data off a list?' (Writing a function that does it doesn't count.) So far, my best solution is "chunk,data = data[:n],data[n:]" where n is the size of your chunk. It looks a little ugly, but is reasonably error-proof and succinct. Chopping off null-terminated strings has a far more satisfying solution: "chunk,data = data.split('\0', 1)". The 1 is the maximum number of times to split - necessary since len(result) must be 2. It provides a great way to cut off several nullstrings at once - "firstname,lastname,data = data.split('\0', 2) 3 is where it gets interesting. One approach I like the feel of is parsing via a generator that takes the data as input, and yields (key,value) pairs for dictionary insertion. Parsing a packet is then "for (k,v) in parseGen(data): packet[k]=v". This seems to provide a clean way to split the parsing into modules if need be (by invoking "for pair in parseGen2(data): yield pair" inside parseGen) and lets you parse a packet partially (if you're only interested up to a certain point) if you want.
|
# ? Jul 15, 2009 09:28 |
|
ATLbeer posted:Has anyone seen a pure Python implementation of a round robin archive type system anywhere? All I know of are: http://code.google.com/p/pyrrd/ http://code.google.com/p/rrdpy/ The latter is from Corey Goldberg, who is wicked smart - he maintains/wrote PyLot http://www.pylot.org/
|
# ? Jul 15, 2009 14:17 |
|
|
# ? May 28, 2024 18:51 |
|
m0nk3yz posted:http://code.google.com/p/pyrrd/
|
# ? Jul 15, 2009 14:27 |